Guest User

Untitled

a guest
Jul 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. class Position < ActiveRecord::Base
  2. include Stocks
  3. belongs_to :trade_set
  4. attr_accessible :symbol, :percent, :shares, :open, :close, :trade_set_id, :name
  5.  
  6. def set_stock_info(symbol, name)
  7. self.name = name
  8. self.symbol = symbol
  9. end
  10.  
  11. def set_position_values(percent, shares, open, close)
  12. self.percent = percent
  13. self.shares = shares
  14. self.open = open
  15. self.close = close
  16. end
  17.  
  18. class Trade_Set < ActiveRecord::Base
  19. belongs_to :user
  20. has_many :positions, :dependent => :destroy
  21. has_many :comments, :dependent => :destroy
  22. belongs_to :trading_period
  23. accepts_nested_attributes_for :positions, :allow_destroy => true
  24. attr_accessible :workflow_state, :cash, :open, :close, :title,
  25. :description, :log, :positions_attributes, :trading_period_id
  26. #...
  27. end
  28.  
  29. create_table "positions", :force => true do |t|
  30. t.string "symbol"
  31. t.integer "percent"
  32. t.integer "shares"
  33. t.decimal "open"
  34. t.decimal "close"
  35. t.integer "trade_set_id"
  36. t.datetime "created_at"
  37. t.datetime "updated_at"
  38. t.string "name"
  39. end
  40.  
  41. Position Load (2.8ms) SELECT "positions".* FROM "positions" WHERE ("positions".trade_set_id = 7)
  42. WARNING: Can't mass-assign protected attributes: created_at, updated_at
  43. WARNING: Can't mass-assign protected attributes: created_at, updated_at
  44. WARNING: Can't mass-assign protected attributes: created_at, updated_at
Add Comment
Please, Sign In to add comment