Class: IshManager::StockOptionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/trash/stock_options_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/ish_manager/trash/stock_options_controller.rb', line 12

def create
  @stock_option = Ish::StockOption.new params[:ish_stock_option].permit!
  @stock_option.profile = current_user.profile
  authorize! :create, @stock_option
  flag = @stock_option.save

  if flag
    flash[:notice] = 'Created stock option.'
  else
    flash[:alert] = "Cannot create stock option: #{@stock_option.errors.messages}"
  end
  redirect_to :action => 'index'
end

#indexObject



4
5
6
7
8
9
10
# File 'app/controllers/ish_manager/trash/stock_options_controller.rb', line 4

def index
  authorize! :index, Ish::StockOption
  @profiles = IshModels::UserProfile.all
  @stock_options = Ish::StockOption.all.includes( :profile )
  @stock_option = Ish::StockOption.new
  render 'index', :layout => 'ish_manager/application_no_materialize'
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/ish_manager/trash/stock_options_controller.rb', line 26

def update
  @stock_option = Ish::StockOption.find params[:id]
  authorize! :update, @stock_option
  flag = @stock_option.update_attributes params[:ish_stock_option].permit!
  if flag
    flash[:notice] = 'Updated stock option.'
  else
    flash[:alert] = "Cannot update stock option: #{@stock_option.errors.messages}"
  end
  redirect_to :action => 'index'
end