Class: IshManager::IroPositionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#basic_auth, #home

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/ish_manager/iro_positions_controller.rb', line 6

def create
  @position = Iro::Position.new({
    iro_purse: @purse = Iro::Purse.find_or_create_by({ user_id: current_user.id }),
    type: 'Iro::CoveredCall',
  })
  authorize! :update, @position

  if @position.update params[:position].permit!
    flash[:notice] = 'Successfully updated position.'
    redirect_to controller: 'iro_purses', action: :show
  else
    flash[:alert] = "Cannot update position: #{@position.errors.full_messages.join(', ')}."
    render action: 'edit'
  end
end

#editObject



22
23
24
25
# File 'app/controllers/ish_manager/iro_positions_controller.rb', line 22

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

#newObject



27
28
29
30
# File 'app/controllers/ish_manager/iro_positions_controller.rb', line 27

def new
  @position = Iro::Position.new
  authorize! :new, @position
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/ish_manager/iro_positions_controller.rb', line 32

def update
  @position = Iro::Position.find params[:id]
  authorize! :update, @position

  if @position.update params[:position].permit!
    flash[:notice] = 'Successfully updated position.'
    redirect_to controller: 'iro_purses', action: :show
  else
    flash[:alert] = "Cannot update position: #{@position.errors.full_messages.join(', ')}."
    render action: 'edit'
  end
end