Class: CmsAdmin::PagesController
- Inherits:
-
BaseController
- Object
- BaseController
- CmsAdmin::PagesController
- Defined in:
- app/controllers/cms_admin/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #form_blocks ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reorder ⇒ Object
- #toggle_branch ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 22 def create @cms_page.save! flash[:notice] = 'Page saved' redirect_to :action => :edit, :id => @cms_page rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to create page' render :action => :new end |
#destroy ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 40 def destroy @cms_page.destroy flash[:notice] = 'Page deleted' redirect_to :action => :index end |
#edit ⇒ Object
18 19 20 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 18 def edit render end |
#form_blocks ⇒ Object
46 47 48 49 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 46 def form_blocks @cms_page = @cms_site.pages.find_by_id(params[:id]) || @cms_site.pages.new @cms_page.layout = @cms_site.layouts.find_by_id(params[:layout_id]) end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 9 def index return redirect_to :action => :new if @cms_site.pages.count == 0 @cms_pages = [@cms_site.pages.root].compact end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 14 def new render end |
#reorder ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 60 def reorder (params[:cms_page] || []).each_with_index do |id, index| if (cms_page = Cms::Page.find_by_id(id)) cms_page.update_attribute(:position, index) end end render :nothing => true end |
#toggle_branch ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 51 def toggle_branch @cms_page = @cms_site.pages.find(params[:id]) s = (session[:cms_page_tree] ||= []) id = @cms_page.id.to_s s.member?(id) ? s.delete(id) : s << id rescue ActiveRecord::RecordNotFound # do nothing end |
#update ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/cms_admin/pages_controller.rb', line 31 def update @cms_page.save! flash[:notice] = 'Page updated' redirect_to :action => :edit, :id => @cms_page rescue ActiveRecord::RecordInvalid flash.now[:error] = 'Failed to update page' render :action => :edit end |