Displaying 1 result from an estimated 1 matches for "relatedel".
Did you mean:
related
2008 Jan 18
2
has_many :through with self-referencial AND polymorphism
...a one way relation, like a www link) with
another Publication, Picture or File
I tried this :
Publication :
has_many :related_elements, :dependent => :destroy, :foreign_key =>
:publication_id
has_many :related, :through => :related_elements, :as => :linked,
:source => :publication
RelatedElement :
belongs_to :publication
And migrate as
create_table :related_elements do |t|
t.integer :linked_id
t.string :linked_type
t.integer :publication_id
end
When I do
a_publication.related[0] = another_publication
a_publication.save!
I would expect the related_elem...