Class: Cms::Admin::FileAttachmentsController
- Inherits:
-
AdminController
- Object
- AdminController
- Cms::Admin::FileAttachmentsController
- Defined in:
- app/controllers/cms/admin/file_attachments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/cms/admin/file_attachments_controller.rb', line 9 def create @page = Page.find(params[:file_attachment].delete('page_id')) @owner = params[:file_attachment][:owner_type].constantize.find(params[:file_attachment][:owner_id]) @file_attachment = @owner..new(params[:file_attachment]) if @file_attachment.save responds_to_parent do render :update do |page| page.replace_html 'new_file_attachment', '' page.replace_html 'file_attachments_container', :partial => 'cms/content/file_attachments_container' end end else responds_to_parent do render :update do |page| page.replace_html "file_attachment_", :partial => 'cms/admin/file_attachments/form' end end end end |
#destroy ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/cms/admin/file_attachments_controller.rb', line 31 def destroy @page = Page.find(params[:page_id]) @file_attachment = FileAttachment.find(params[:id]) @file_attachment.destroy render :update do |page| page.replace_html 'file_attachments_container', :partial => 'cms/content/file_attachments_container' end end |
#new ⇒ Object
3 4 5 6 7 |
# File 'app/controllers/cms/admin/file_attachments_controller.rb', line 3 def new @page = Page.find(params[:page_id]) @file_attachment = FileAttachment.new render :partial => 'cms/admin/file_attachments/form' end |
#sort ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/cms/admin/file_attachments_controller.rb', line 40 def sort @page = Page.find(params[:page_id]) if params[:file_attachment] position = 0 params[:file_attachment].each do |id| = FileAttachment.find(id) .update_attributes(:position => position) position += 1 end end render :nothing => true, :layout => false end |