-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
In specifying an objects polymorphic relation (say :object), three fields are being created: object_type, object_field, object_id.
type and id are typical but I've never seen field before and was just wondering what it is there for? (I don't see any use)
I did the following in a rails (3.2.11) console that has a mongoid (3.1.2) database
1.9.3-p194 :009 > class TestObject 1.9.3-p194 :010?> include Mongoid::Document 1.9.3-p194 :011?> belongs_to :object, polymorphic: true 1.9.3-p194 :012?> end => #<Mongoid::Relations::Metadata ... > 1.9.3-p194 :013 > TestObject.new => #<TestObject _id: 518d7d75330eb976d2000002, object_type: nil, object_field: nil, object_id: nil> 1.9.3-p194 :014 > TestObject.new( object: TestObject.create ) => #<TestObject _id: 518d7de5330eb976d2000004, object_type: "TestObject", object_field: nil, object_id: "518d7de5330eb976d2000003">