Class: Admin::PagesController
- Inherits:
-
AdminController
- Object
- AdminController
- Admin::PagesController
- Defined in:
- app/controllers/pages_cms/admin/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #preview ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #version_up ⇒ Object
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 10 def create page = Page.new(page_params) if page.save redirect_to admin_page_path page else redirect_to :back end end |
#destroy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 42 def destroy Page.find(params[:id]).destroy flash[:success] = 'Page Deleted.' redirect_to :back end |
#index ⇒ Object
3 4 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 3 def index end |
#preview ⇒ Object
37 38 39 40 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 37 def preview @page = Page.find(params[:page_id]) render layout: 'layouts/application' end |
#show ⇒ Object
6 7 8 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 6 def show @page = Page.find(params[:id]) end |
#update ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 19 def update page = Page.find(params[:id]) if page.update(page_params) render json: {message: 'Page Updated.'} else render json: {message: page.errors..to_sentence } end end |
#version_up ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/pages_cms/admin/pages_controller.rb', line 28 def version_up page = Page.find(params[:page_id]) if page.update(version: page.version ? page.version + 1 : 0) render json: {message: 'Page Published.'} else render json: {message: page.errors..to_sentence } end end |