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
Search for "Rails double polymorphic" in Google...
http://wiki.rubyonrails.org/rails/pages/ManytoManyPolymorphicAssociations
http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/files/README.html
or just assume that everyone else will do the googling for you...
--
Posted via http://ww
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
Reiner,
My suggestion then is to come up with your classes first and then make a
design. A very common pitfall is to design for something that "may"
happen and then later face over engineered code.. In the late nineties,
we called this the YAGNI principle which stood for "You Aint Going to
N
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
Reiner,
I don't believe you have the need for polymorphic associations in the
above example as you have a seperate association "type" already specced
out for each relation
class Person < ActiveRecord::Base
has_many :documents
has_many :realties
end
class Document < ActiveRecord::Base
belongs_
6 matches
Mail list logo