Skip to content

Instantly share code, notes, and snippets.

@tjarmain
Created July 31, 2012 06:37
Show Gist options
  • Save tjarmain/3214287 to your computer and use it in GitHub Desktop.
Save tjarmain/3214287 to your computer and use it in GitHub Desktop.
class Stock < ActiveRecord::Base
attr_accessible :issuer, :portfolio_id
has_many :portfolios_stocks
has_many :portfolios, :through => :portfolios_stocks
end
class Portfolio < ActiveRecord::Base
attr_accessible :fund_id, :period
belongs_to :fund
has_many :portfolios_stocks
has_many :stocks, :through => :portfolios_stocks
end
class Fund < ActiveRecord::Base
attr_accessible :name
has_many :portfolios
end
@certainty
Copy link

class PortfolioStock < ActiveRecord::Base
  self.table_name='portfolios_stocks'

  belongs_to :stock
  belongs_to :portfolio
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment