Displaying 1 result from an estimated 1 matches for "linked_typ".
Did you mean:
linked_type
2008 Jan 18
2
has_many :through with self-referencial AND polymorphism
...t => :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_elements table beeing updated with
publication_id = the id of a_publication
linked_id = the id of another_publication
linked_type = the class name '...