[Rails] Re: How to model a polymorphic relationship?

2008-09-18 Thread Reiner Pittinger
I came to the solution using the has_many_polymorphs plugins: The correct modelling is: class Relationship < ActiveRecord::Base belongs_to :relationship_owner, :polymorphic => true belongs_to :relationship_partner, :polymorphic => true acts_as_double_polymorphic_join( :relationsh

[Rails] Re: How to model a polymorphic relationship?

2008-09-10 Thread Reiner Pittinger
Dear Ilan, although I just supplied just three basic models, my application already contains more than 15 different models that should be linked to each other. Some more examples: - I need a relationship between two documents ("Like: Document B is an attachment to Document A). - I need a rel

[Rails] Re: How to model a polymorphic relationship?

2008-09-09 Thread Reiner Pittinger
Hi Ilan, thank you for your answer: Ilan Berci wrote: > class Person < ActiveRecord::Base > has_many :documents > has_many :realties > end > > class Document < ActiveRecord::Base > belongs_to :owner, class_name => "Person" > belongs_to :realty > end > > class Realty < ActiveRecord::Base > bel

[Rails] How to model a polymorphic relationship?

2008-09-09 Thread Reiner Pittinger
I have read many articles about polymorphic associations in Rails and also about plugins for this purpose (mainly the has_many_polymorphs plugin). Unfortunately, I am still unsure how to solve my problem: Let's say you have these models you want to set in relation to each other: Person, Document