Class: Kuhsaft::Cms::PagesController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- ApplicationController
- AdminController
- Kuhsaft::Cms::PagesController
- Defined in:
- app/controllers/kuhsaft/cms/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from AdminController
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 20 def create @page = Kuhsaft::Page.create params[:page] if @page.valid? respond_with @page, :location => kuhsaft.edit_cms_page_path(@page) else render 'new' end end |
#destroy ⇒ Object
49 50 51 52 53 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 49 def destroy @page = Kuhsaft::Page.find(params[:id]) @page.destroy redirect_to kuhsaft.cms_pages_path end |
#edit ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 30 def edit @page = Kuhsaft::Page.find(params[:id]) @page.published ||= Kuhsaft::PublishState::UNPUBLISHED respond_with @page end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 4 def index @pages = Kuhsaft::Page.roots respond_with @pages end |
#new ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 14 def new @page = Kuhsaft::Page.new @page.published ||= Kuhsaft::PublishState::UNPUBLISHED respond_with @page end |
#show ⇒ Object
9 10 11 12 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 9 def show @page = Kuhsaft::Page.find(params[:id]) respond_with @page end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 36 def update @page = Kuhsaft::Page.find(params[:id]) @page.update_attributes(params[:page]) if params[:page].present? # TODO: refactor 'reposition' as a page attribute, so it can be set through update_attributes @page.reposition params[:reposition] if params[:reposition].present? || params.key?(:reposition) if params[:add_page_part].present? @page.bricks << params[:page][:page_part_type].constantize.new end respond_with @page, :location => kuhsaft.edit_cms_page_path(@page) end |