Hi, I gotta make a model (telefone) that belongs to a person or to a
company, how do I do that?
Thank you,
Rodrigo
Hi, I gotta make a model (telefone) that belongs to a person or to a
company, how do I do that?
Thank you,
Rodrigo
On Sep 21, 2011, at 9:52 PM, Rodrigo R. 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
-Rob
Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/
thank you
On Thu, Sep 22, 2011 at 12:43 AM, Rob B.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs