Friday, March 25, 2011

[Rails] Re: shared primary key (using the primary key as a foreign key for has_one association)

Just on more related question (if anyone has time to answer):

if i have set_primary_key 'person_id':

class Instructor < ActiveRecord::Base
set_primary_key 'person_id'
...
end

does it mean that writing

class Person < ActiveRecord::Base
has_one :instructor, :primary_key => 'person_id'
end

would be redundant?
What is the purpose of :primary_key in has_one options, if one uses
set_primary_key ?

Thanks.

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate