It is certainly "possible" to do what you're describing, and yes, the same 
person *could* be both an instructor and a member at the same time.

However, I'll second Colin's suggestion that you just follow the convention 
to have a separate id primary key column in both the instructors and members 
tables. The extra bytes-per-record in your database will be worth the lack 
of hassle, even if you grow to many millions of records.

Now, if you insist on doing it the way you describe, you'll need to use the 
#set_primary_key macro method in your models:

class Instructor
  set_primary_key "person_id"
  ...
end

You'll also need to be sure to explicitly set the primary key value when 
creating your instructor and member records. If you do this through your 
has_one relationship (person.create_instructor for example) it *may* do this 
for you. I don't know for sure, never tried this. Test it out and see.

Likewise, I'm guessing that your relationship definitions (since you're 
using the "person_id" name) won't need any tweaking. But again, test and see 
(to be sure you won't need to provide :primary_key and/or :foreign_key 
options to your belongs_to and/or has_one relationship definitions).

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to