Class: Activa::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Activa::PagesController
- Defined in:
- app/controllers/activa/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #position ⇒ Object
- #show ⇒ Object
- #slug ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/activa/pages_controller.rb', line 29 def create @page = Activa::Page.new(params[:page]) # Publish page immediately if params[:commit].present? if @page.publish flash.notice = I18n.t 'controllers.pages.create.published_notice' smart_redirect_to(@page) and return end # Save page as a draft and continue editing elsif params[:save_as_draft].present? if @page.save_as_draft flash.notice = I18n.t 'controllers.pages.create.draft_notice' redirect_to(activa.edit_page_path(@page)) and return end end respond_with(@page) end |
#destroy ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'app/controllers/activa/pages_controller.rb', line 65 def destroy if @page.destroy flash.notice = I18n.t 'controllers.pages.destroy.notice' redirect_to(activa.pages_path) and return end respond_with(@page) and return end |
#edit ⇒ Object
25 26 27 |
# File 'app/controllers/activa/pages_controller.rb', line 25 def edit end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/activa/pages_controller.rb', line 10 def index @pages = Activa::Page.roots end |
#new ⇒ Object
18 19 20 21 22 23 |
# File 'app/controllers/activa/pages_controller.rb', line 18 def new @page = Activa::Page.new @page.parent_id = params[:parent_id].to_i respond_with(@page) end |
#position ⇒ Object
78 79 80 81 82 83 84 |
# File 'app/controllers/activa/pages_controller.rb', line 78 def position render :json => Activa::Page.move( params[:first_node_id], params[:second_node_id], params[:nesting] ) end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/activa/pages_controller.rb', line 14 def show end |
#slug ⇒ Object
74 75 76 |
# File 'app/controllers/activa/pages_controller.rb', line 74 def slug render :json => { :slug => params[:title].to_s.to_url } end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/activa/pages_controller.rb', line 49 def update if params[:commit].present? if @page.update_attributes(params[:page])#@page.publish#(params[:page]) flash.notice = I18n.t 'controllers.pages.create.published_notice' smart_redirect_to(@page) and return end elsif params[:save_as_draft].present? if @page.update_as_draft(params[:page]) redirect_to(activa.edit_page_path(@page)) and return end end respond_with(@page) end |