Class: SimpleShowcaseAdmin::ItemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SimpleShowcaseAdmin::ItemsController
- Defined in:
- app/controllers/simple_showcase_admin/items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ 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 28 29 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 20 def create @category = SimpleShowcaseAdmin::Category.find(params[:category_id]) @item = @category.items.new(params[:item]) if @item.save redirect_to category_item_path(@category, @item), notice: "Successful created #{@item.title.downcase}" else @photos = @item.photos.blank? ? @item.photos.new : @item.photos render :new end end |
#destroy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 42 def destroy @item = SimpleShowcaseAdmin::Item.find(params[:id]) @item.destroy redirect_to category_path(params[:category_id]), notice: "Successfully deleted #{@item.title}" end |
#edit ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 8 def edit @item = SimpleShowcaseAdmin::Item.find(params[:id]) @category = SimpleShowcaseAdmin::Category.find(params[:category_id]) @photos = @item.photos.blank? ? @item.photos.new : @item.photos end |
#new ⇒ Object
3 4 5 6 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 3 def new @item = SimpleShowcaseAdmin::Item.new @photos = @item.photos.new end |
#show ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 14 def show @item = SimpleShowcaseAdmin::Item.find(params[:id]) @category = SimpleShowcaseAdmin::Category.find(params[:category_id]) @photos = @item.photos end |
#sort ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 48 def sort @item = SimpleShowcaseAdmin::Item.find(params[:id]) @item.row_order_position = params[:row_order_position] @item.save! render nothing: true end |
#update ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/simple_showcase_admin/items_controller.rb', line 31 def update @category = SimpleShowcaseAdmin::Category.find(params[:category_id]) @item = SimpleShowcaseAdmin::Item.find(params[:id]) if @item.update_attributes!(params[:item]) redirect_to category_item_path(@category, @item) else @photos = @item.photos.blank? ? @item.photos.new : @item.photos render :edit end end |