Class: Admin::PagesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Admin::PagesController
- Defined in:
- app/controllers/admin/pages_controller.rb
Instance Method Summary collapse
- #archive ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #publish ⇒ Object
- #unarchive ⇒ Object
- #unpublish ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Methods included from BaseHelper
Instance Method Details
#archive ⇒ Object
60 61 62 63 64 |
# File 'app/controllers/admin/pages_controller.rb', line 60 def archive page = Page.find(params[:id]) page.archive! redirect_to admin_pages_path end |
#create ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/admin/pages_controller.rb', line 20 def create @page = Page.new(params[:page]) if @page.save redirect_to admin_pages_path else render :new end end |
#destroy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/admin/pages_controller.rb', line 42 def destroy page = Page.find(params[:id]) page.destroy redirect_to admin_pages_path end |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/admin/pages_controller.rb', line 29 def edit @page = Page.find(params[:id]) end |
#index ⇒ Object
11 12 13 14 |
# File 'app/controllers/admin/pages_controller.rb', line 11 def index @search = Page.includes(:category).search(params[:search]) @pages = @search.order("created_at desc").page(params[:page]) end |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/admin/pages_controller.rb', line 16 def new @page = Page.new end |
#publish ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/admin/pages_controller.rb', line 48 def publish page = Page.find(params[:id]) page.publish! redirect_to admin_pages_path end |
#unarchive ⇒ Object
66 67 68 69 70 |
# File 'app/controllers/admin/pages_controller.rb', line 66 def unarchive page = Page.find(params[:id]) page.unarchive! redirect_to admin_pages_path end |
#unpublish ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/admin/pages_controller.rb', line 54 def unpublish page = Page.find(params[:id]) page.unpublish! redirect_to admin_pages_path end |
#update ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/admin/pages_controller.rb', line 33 def update @page = Page.find(params[:id]) if @page.update_attributes(params[:page]) redirect_to admin_pages_path else render :edit end end |