Should I define models that will be owned by many different models or use controller and views?
Posted
by
jgervin
on Stack Overflow
See other posts from Stack Overflow
or by jgervin
Published on 2012-11-21T22:47:15Z
Indexed on
2012/11/21
22:59 UTC
Read the original article
Hit count: 268
ruby-on-rails
|ruby
I am struggling to figure out how to get a relationship between several models. I have sales_leads which I need to view by company and by event. So if someone looks up the leads by company they can see all leads across all events, but also see all leads by event. Not sure if this is ownership versus a where?
Should it be something like
Company.sales_leads where("event.event_id = ?", "2356")
Or Models:
sales_lead
belongs_to event
belongs_to company
© Stack Overflow or respective owner