clio / polymorphic_integer_type

MIT License
37 stars 35 forks source link

Using the method collection<< to add an item to a polymorphic object does not assign the type to the item #14

Closed jogaco closed 10 months ago

jogaco commented 9 years ago

With "standard" string type, rails takes care of assigning the correct type to the new element:

class Animal < ActiveRecord::Base
  has_many :source_links, , :as => :source
end

class Link < ActiveRecord::Base
  belongs_to :source, :polymorphic => true
end

a = Animal.create
a.source_links << Link.new
a.first.source_type
=> 'Animal'