Class: SimpleShowcaseAdmin::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SimpleShowcaseAdmin::CategoriesController
- Defined in:
- app/controllers/simple_showcase_admin/categories_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
20 21 22 23 24 25 26 27 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 20 def create @category = SimpleShowcaseAdmin::Category.new(params[:category]) if @category.save redirect_to [ @category], notice: 'Successfully created new category' else render :new end end |
#destroy ⇒ Object
38 39 40 41 42 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 38 def destroy @category = SimpleShowcaseAdmin::Category.find(params[:id]) @category.destroy redirect_to categories_path end |
#edit ⇒ Object
11 12 13 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 11 def edit @category = SimpleShowcaseAdmin::Category.find(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 3 def index @categories = SimpleShowcaseAdmin::Category.rank(:row_order).page(params[:page]).per(10) end |
#new ⇒ Object
7 8 9 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 7 def new @category = SimpleShowcaseAdmin::Category.new end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 15 def show @category = SimpleShowcaseAdmin::Category.find(params[:id]) @items = Item.where(category_id: @category.id).rank(:row_order).page(params[:page]).per(10) end |
#sort ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 44 def sort @category = SimpleShowcaseAdmin::Category.find(params[:id]) @category.row_order_position = params[:row_order_position] @category.save! render nothing: true end |
#update ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/controllers/simple_showcase_admin/categories_controller.rb', line 29 def update @category = SimpleShowcaseAdmin::Category.find(params[:id]) if @category.update_attributes(params[:category]) redirect_to category_path(@category), notice: 'Successfully updated category' else render :edit end end |