0

I have here the behaviour that in one of my collection the _type field was not populated, what in my case is really needed.

scenario 'User edits a session' do
   session = survey.sessions.create version: version, token: 'xxx'

produces a database entry like that without , _type: 'Helena::Session'...

{ _id: ObjectId("5458f7b16861632f09020000"), 
token: "xxx", 
version_id: ObjectId("5458f7b16861632f09010000"), 
completed: false, survey_id: ObjectId("5458f7b16861632f09000000"), 
updated_at: ISODate("2014-11-04T15:58:41.541Z"), 
created_at: ISODate("2014-11-04T15:58:41.541Z"), 
view_token: "VEXfJNjyr3yI4GIziqTxrsHC9" }

I explicit have to pass the type. Is there a way to enforce the _type even if it's not a derived object?

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Markus Graf
  • 533
  • 3
  • 16
  • Why do you need the `_type` if you're not using SCI? Wouldn't it always be the same? – mu is too short Nov 04 '14 at 17:44
  • because i am getting `undefined method _type=' for # mongoid (4.0.0) lib/mongoid/attributes/dynamic.rb, line 136`. But you could be right, perhaps its rather a bug in `Mongoid::Attributes::Dynamic` – Markus Graf Nov 07 '14 at 08:52

0 Answers0