thank you On Thu, Sep 22, 2011 at 12:43 AM, Rob Biedenharn <r...@agileconsultingllc.com> wrote: > > On Sep 21, 2011, at 9:52 PM, Rodrigo Ruiz wrote: > >> Hi, I gotta make a model (telefone) that belongs to a person or to a >> company, how do I do that? >> >> Thank you, >> Rodrigo > > You probably want a polymophic association: > > class Telefone < ActiveRecord::Base > belongs_to :owner, :polymorphic => true > end > > class Person < ActiveRecord::Base > has_many :telefones, :as => :owner > end > > class Company < ActiveRecord::Base > has_many :telefones, :as => :owner > end > > See the information at > http://guides.rubyonrails.org/association_basics.html#polymorphic-associations > > -Rob > > Rob Biedenharn > r...@agileconsultingllc.com http://AgileConsultingLLC.com/ > r...@gaslightsoftware.com http://GaslightSoftware.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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >
-- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.