Class: Comable::Admin::StocksController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Comable::Admin::StocksController
- Defined in:
- app/controllers/comable/admin/stocks_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 20 def create if @stock.update_attributes(stock_params) redirect_to comable.admin_product_stock_path(@product, @stock), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :new end end |
#destroy ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 38 def destroy if @stock.destroy redirect_to comable.admin_product_stocks_path(@product), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |
#index ⇒ Object
15 16 17 18 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 15 def index @q = @product.stocks.ransack(params[:q]) @stocks = @q.result.includes(:product).page(params[:page]).accessible_by(current_ability) end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 11 def show render :edit end |
#update ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 29 def update if @stock.update_attributes(stock_params) redirect_to comable.admin_product_stock_path(@product, @stock), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |