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
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 23 def create if @stock.save redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :new end end |
#destroy ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 44 def destroy if @stock.destroy redirect_to comable.admin_stocks_path, notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |
#edit ⇒ Object
32 33 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 32 def edit end |
#index ⇒ Object
11 12 13 14 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 11 def index @q = @stocks.ransack(params[:q]) @stocks = @q.result.includes(:product).page(params[:page]).accessible_by(current_ability) end |
#new ⇒ Object
20 21 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 20 def new end |
#show ⇒ Object
16 17 18 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 16 def show render :edit end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/comable/admin/stocks_controller.rb', line 35 def update if @stock.update_attributes(stock_params) redirect_to comable.admin_stock_path(@stock), notice: Comable.t('successful') else flash.now[:alert] = Comable.t('failure') render :edit end end |