I have a model class Person < ActiveRecord::Base and 2 classes inheriting from it class User < Person and class Contact < Person obviously the id is person.id but is there anyway to use user.id and contact.id or should I always use person.id ??? thanks for your suggestions erwin --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-07 13:48 UTC
Re: single table inheritance , how to alias the id key name ?
On 7 May 2008, at 14:27, Erwin wrote:> > I have a model class Person < ActiveRecord::Base > and 2 classes inheriting from it > class User < Person and class Contact < Person > > obviously the id is person.id > but is there anyway to use user.id and contact.id or should I > always use person.id ??? >Your question doesn''t really make a huge amount of sent. If foo is an instance of person, user, contact (or any other AR model for that matter) the foo.id gives you the primary key Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---