[Rails] Re: Re: Re: Modelling Foreign Keys

Arch Stanton d6veteran at gmail.com
Sat Apr 1 03:41:47 GMT 2006


Chris Hall wrote:
> you're not getting anything.  Rails figures out that info based on the
> criteria you specify.  if you stick to Rails conventions, you don't have 
> to
> do anything but provide the association name, rails does the rest.
> 
> so in that example
> 
> student belongs_to :advisor
> 
> rails will make the following assumptions:
> 
> students table contains an "advisor_id" column that references the id 
> column
> in advisors table
> the associated class is named "Advisor"
> 


I guess I do have a follow up question.

In the above example, what is gained by adding a has_many relationship 
to Advisor?

advisor has_many :students

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list