Class: Cms::Admin::PageContentBlocksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Cms::Admin::PageContentBlocksController
- Defined in:
- app/controllers/cms/admin/page_content_blocks_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 15 def create @page = Page.find(params[:page_content_block][:page_id]) @page_content_block = @page.page_content_blocks.new(params[:page_content_block]) if @page_content_block.save responds_to_parent do render :update do |page| page.replace_html 'new_page_content_block', '' page.replace_html 'page_content_blocks_container', :partial => 'cms/content/page_content_blocks_container' end end else responds_to_parent do render :update do |page| page.replace_html "page_content_block_", :partial => 'cms/admin/page_content_blocks/form' end end end end |
#destroy ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 56 def destroy @page_content_block = PageContentBlock.find(params[:id]) @page = Page.find(@page_content_block.page_id) @page_content_block.destroy render :update do |page| page.replace_html 'page_content_blocks_container', :partial => 'cms/content/page_content_blocks_container' end end |
#edit ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 9 def edit @page_content_block = PageContentBlock.find(params[:id]) @page = Page.find(@page_content_block.page_id) render :partial => 'cms/admin/page_content_blocks/form' end |
#new ⇒ Object
3 4 5 6 7 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 3 def new @page = Page.find(params[:page_id]) @page_content_block = @page.page_content_blocks.new render :partial => 'cms/admin/page_content_blocks/form' end |
#sort ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 65 def sort @page = Page.find(params[:page_id]) if params[:page_content_block] position = 0 params[:page_content_block].each do |id| page_content_block = @page.page_content_blocks.find(id) page_content_block.update_attributes(:position => position) position += 1 end end render :nothing => true, :layout => false end |
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/cms/admin/page_content_blocks_controller.rb', line 35 def update @page_content_block = PageContentBlock.find(params[:id]) @page = Page.find(@page_content_block.page_id) @page_content_block.photo = nil if params[:remove_image] if @page_content_block.update_attributes(params[:page_content_block]) responds_to_parent do render :update do |page| page.replace_html 'page_content_blocks_container', :partial => 'cms/content/page_content_blocks_container' end end else responds_to_parent do render :update do |page| page.replace_html "page_content_block_", :partial => 'cms/admin/page_content_blocks/form' end end end end |