Class: Admin::PageAttachmentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/page_attachments_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



38
39
40
41
42
43
44
45
# File 'app/controllers/admin/page_attachments_controller.rb', line 38

def destroy
	if request.post?
		@attachment = PageAttachment.find(params[:id])
		page = @attachment.page
		@attachment.destroy
		render :partial => 'admin/page/attachment', :layout => false, :collection => page.attachments
	end
end

#editObject



10
11
12
# File 'app/controllers/admin/page_attachments_controller.rb', line 10

def edit
  @page_attachment = PageAttachment.find(params[:id])
end

#gridObject



6
7
8
# File 'app/controllers/admin/page_attachments_controller.rb', line 6

def grid
  @attachments = PageAttachment.paginate :per_page => 25, :page => params[:page], :conditions => {:parent_id => nil}, :order => 'title, filename'
end

#indexObject



3
4
5
# File 'app/controllers/admin/page_attachments_controller.rb', line 3

def index
  @attachments = PageAttachment.paginate :per_page => 25, :page => params[:page], :conditions => {:parent_id => nil}, :order => 'title, filename'
end

#move_higherObject



22
23
24
25
26
27
28
# File 'app/controllers/admin/page_attachments_controller.rb', line 22

def move_higher
	if request.post?
		@attachment = PageAttachment.find(params[:id])
		@attachment.move_higher
		render :partial => 'admin/page/attachment', :layout => false, :collection => @attachment.page.attachments
	end
end

#move_lowerObject



30
31
32
33
34
35
36
# File 'app/controllers/admin/page_attachments_controller.rb', line 30

def move_lower
	if request.post?
		@attachment = PageAttachment.find(params[:id])
		@attachment.move_lower
		render :partial => 'admin/page/attachment', :layout => false, :collection => @attachment.page.attachments
	end
end

#updateObject



13
14
15
16
17
18
19
20
# File 'app/controllers/admin/page_attachments_controller.rb', line 13

def update
  @page_attachment = PageAttachment.find(params[:id])
  if @page_attachment.update_attributes(params[:page_attachment])
    redirect_to admin_page_attachments_url
  else
    render :edit
  end
end