-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Mongoid is not setting type field on polymorphic associations
mongoid (4.0.0): df7f1fdd419c8613d53952992d9f5d233292db36 moped (1.5.0) origin (1.1.0) rails (4.0.0.rc1)
class User include Mongoid::Document include Mongoid::Timestamps has_many :payments, inverse_of: :to end
class Payment include Mongoid::Document include Mongoid::Timestamps field :amount, type: Integer belongs_to :to, polymorphic: true belongs_to :from, polymorphic: true end
u = User.first u.payments.create(from: Organization.first, amount: -1) => #<Payment _id: 519c71c6dc112ac376000001, amount: -1, to_type: nil, to_id: "519b1e4ddc112a0da7000001", from_type: "Organization", from_id: "519b1ea1dc112a2243000004">
as you can see to_type is nil, this was working in previous revisions...