Model that belongs to Person or Company

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

-Rob

Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/

thank you