Class: SimpleShowcaseAdmin::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SimpleShowcaseAdmin::PagesController
- Defined in:
- app/controllers/simple_showcase_admin/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 19 def create @page = SimpleShowcaseAdmin::Page.new(params[:page]) if @page.save redirect_to [ @page], notice: 'Successfully created new page' else render :new end end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 37 def destroy @page = SimpleShowcaseAdmin::Page.find(params[:id]) @page.destroy redirect_to pages_path end |
#edit ⇒ Object
11 12 13 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 11 def edit @page = SimpleShowcaseAdmin::Page.find(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 3 def index @pages = SimpleShowcaseAdmin::Page.rank(:row_order).page(params[:page]).per(10) end |
#new ⇒ Object
7 8 9 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 7 def new @page = SimpleShowcaseAdmin::Page.new end |
#show ⇒ Object
15 16 17 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 15 def show @page = SimpleShowcaseAdmin::Page.find(params[:id]) end |
#sort ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 43 def sort @page = SimpleShowcaseAdmin::Page.find(params[:id]) @page.row_order_position = params[:row_order_position] @page.save! render nothing: true end |
#update ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/simple_showcase_admin/pages_controller.rb', line 28 def update @page = SimpleShowcaseAdmin::Page.find(params[:id]) if @page.update_attributes(params[:page]) redirect_to page_path(@page), notice: 'Successfully updated page' else render :edit end end |