-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
When using first_or_initialize on a model with a polymorphic association the type field is not set.
class Car include Mongoid::Document belongs_to :drivable, polymorphic: true end class Driver include Mongoid::Document has_many :cars, as: :drivable end driver = Driver.create Car.where(drivable: driver).first_or_initialize #=> #<Car _id: 5587e09d7661671716010000, drivable_type: nil, drivable_id: BSON::ObjectId('5587e0997661671716000000')>