Class: IshManager::IroStrategiesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#basic_auth, #home, #tinymce

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/ish_manager/iro_strategies_controller.rb', line 4

def create
  @strategy = Iro::CoveredCallStrategy.new params[:iro_strategy].permit!
  # @strategy.iro_purse_id = Iro::Purse.where( user_id: current_user.id ).first.id
  authorize! :create, @strategy
  flag = @strategy.save
  if flag
    flash[:notice] = 'Success.'
    redirect_to controller: 'ish_manager/iro_purses', action: :show, id: @strategy.iro_purse_id
  else
    flash[:alert] = "No luck: #{@strategy.errors.full_messages.join(', ')}."
    render action: 'new'
  end
end

#editObject



18
19
20
21
# File 'app/controllers/ish_manager/iro_strategies_controller.rb', line 18

def edit
  @strategy = Iro::CoveredCallStrategy.find params[:id]
  authorize! :edit, @strategy
end

#newObject



23
24
25
26
# File 'app/controllers/ish_manager/iro_strategies_controller.rb', line 23

def new
  @strategy = Iro::CoveredCallStrategy.new
  authorize! :new, @strategy
end

#updateObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/ish_manager/iro_strategies_controller.rb', line 28

def update
  @strategy = Iro::CoveredCallStrategy.find params[:id]
  authorize! :update, @strategy
  flag = @strategy.update params[:iro_strategy].permit!
  if flag
    flash[:notice] = 'Success.'
    redirect_to controller: 'ish_manager/iro_purses', action: :show, id: @strategy.iro_purse_id
  else
    flash[:alert] = "No luck: #{@strategy.errors.full_messages.join(', ')}."
    render action: 'new'
  end
end