Class: IshManager::IroPursesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::IroPursesController
- Defined in:
- app/controllers/ish_manager/iro_purses_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/ish_manager/iro_purses_controller.rb', line 6 def create @iro_purse = Iro::Purse.new({ profile_id: current_profile.id, }) :create, @iro_purse if @iro_purse.update params[:iro_purse].permit! flash[:notice] = 'Successfully created iro_purse.' redirect_to action: :show, id: @iro_purse.id else flash[:alert] = "Cannot create iro_purse: #{@iro_purse.errors..join(', ')}." render action: 'edit' end end |
#edit ⇒ Object
21 22 23 24 |
# File 'app/controllers/ish_manager/iro_purses_controller.rb', line 21 def edit @iro_purse = Iro::Purse.find params[:id] :edit, @iro_purse end |
#new ⇒ Object
26 27 28 29 |
# File 'app/controllers/ish_manager/iro_purses_controller.rb', line 26 def new @iro_purse = Iro::Purse.new :new, @iro_purse end |
#show ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/ish_manager/iro_purses_controller.rb', line 31 def show @purse = Iro::Purse.find params[:id] :my, @purse @strategies = @purse.strategies = Tda::Stock.get_quotes( @strategies.map(&:ticker).compact.uniq.join(",") ) # json_puts! underlyings, 'out' .each do |ticker, v| Iro::CoveredCallStrategy.where( ticker: ticker ).update( current_underlying_strike: v[:mark] ) end @positions = @purse.positions.order({ expires_on: :asc, strike: :asc }) @positions.map &:refresh render @purse.parsed_config[:kind] || 'show' end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/ish_manager/iro_purses_controller.rb', line 49 def update @iro_purse = Iro::Purse.find params[:id] :update, @iro_purse if @iro_purse.update params[:iro_purse].permit! flash[:notice] = 'Successfully updated iro_purse.' redirect_to action: :show, id: @iro_purse.id else flash[:alert] = "Cannot update iro_purse: #{@iro_purse.errors..join(', ')}." render action: 'edit' end end |