Sha256: 43a4542be644bf41947de57410fffb4f62e2893309c4283d72e5df7df9691c28

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

class ::IshManager::IroPositionsController < IshManager::ApplicationController

  before_action :set_lists

  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

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

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

  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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ish_manager-0.1.8.408 app/controllers/ish_manager/iro_positions_controller.rb
ish_manager-0.1.8.407 app/controllers/ish_manager/iro_positions_controller.rb
ish_manager-0.1.8.406 app/controllers/ish_manager/iro_positions_controller.rb
ish_manager-0.1.8.405 app/controllers/ish_manager/iro_positions_controller.rb
ish_manager-0.1.8.404 app/controllers/ish_manager/iro_positions_controller.rb
ish_manager-0.1.8.403 app/controllers/ish_manager/iro_positions_controller.rb