Class: Comable::Admin::ProductsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Comable::Admin::ProductsController
- Defined in:
- app/controllers/comable/admin/products_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/comable/admin/products_controller.rb', line 20 def create if @product.save redirect_to comable.admin_product_path(@product), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :new end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'app/controllers/comable/admin/products_controller.rb', line 41 def destroy if @product.destroy redirect_to comable.admin_products_path, notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |
#edit ⇒ Object
29 30 |
# File 'app/controllers/comable/admin/products_controller.rb', line 29 def edit end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/comable/admin/products_controller.rb', line 8 def index @q = Comable::Product.ransack(params[:q]) @products = @q.result(distinct: true).includes(:stocks, :images).page(params[:page]).accessible_by(current_ability) end |
#new ⇒ Object
17 18 |
# File 'app/controllers/comable/admin/products_controller.rb', line 17 def new end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/comable/admin/products_controller.rb', line 13 def show render :edit end |
#update ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/comable/admin/products_controller.rb', line 32 def update if @product.update_attributes(product_params) redirect_to comable.admin_product_path(@product), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |