Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Position < ActiveRecord::Base
- include Stocks
- belongs_to :trade_set
- attr_accessible :symbol, :percent, :shares, :open, :close, :trade_set_id, :name
- def set_stock_info(symbol, name)
- self.name = name
- self.symbol = symbol
- end
- def set_position_values(percent, shares, open, close)
- self.percent = percent
- self.shares = shares
- self.open = open
- self.close = close
- end
- class Trade_Set < ActiveRecord::Base
- belongs_to :user
- has_many :positions, :dependent => :destroy
- has_many :comments, :dependent => :destroy
- belongs_to :trading_period
- accepts_nested_attributes_for :positions, :allow_destroy => true
- attr_accessible :workflow_state, :cash, :open, :close, :title,
- :description, :log, :positions_attributes, :trading_period_id
- #...
- end
- create_table "positions", :force => true do |t|
- t.string "symbol"
- t.integer "percent"
- t.integer "shares"
- t.decimal "open"
- t.decimal "close"
- t.integer "trade_set_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "name"
- end
- Position Load (2.8ms) SELECT "positions".* FROM "positions" WHERE ("positions".trade_set_id = 7)
- WARNING: Can't mass-assign protected attributes: created_at, updated_at
- WARNING: Can't mass-assign protected attributes: created_at, updated_at
- WARNING: Can't mass-assign protected attributes: created_at, updated_at
Add Comment
Please, Sign In to add comment