-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:
When switching from collection at runtime, some documents, don't get stored in the expected collection.
I've got this problem in multiple documents with a include (ActiveSupport::Concern based).
And it happens most of the time when calling macros. (field doesn't seem to have this effect.)
> Persisting using with is a one time switch in the persistence context - it changes back to its defaults immediately after.
I've seen this section in the documentation, but this doesn't seems to be the problem.
With Mongoid::Versioning included
ruby class Person include Mongoid::Document include Mongoid::Versioning field :name, type: String end # run p = Person.new(name: "johnmalkovich") p.with(collection: "acme.persons").save!
`
Expected results to be stored in collection acme.persons instead stored into people
Removing the include Mongoid::Versioning solves this issue.
ruby class Person ... # include Mongoid::Versioning ... end # run p = Person.new(name: "johnmalkovich") p.with(collection: "acme.persons").save!
`
Result stored in collection acme.persons
Used development Rails application, and stand-alone test-environment.
* rails (3.2.11) * activemodel (3.2.11) * activesupport (3.2.11) * mongoid (3.0.19) * moped (1.3.2) * origin (1.0.11)
`