-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
When methods are chained on a criteria, the write method's attributes should override shared attributes in the criteria's selector. This is the behavior of ActiveRecord and should be emulated in Mongoid.
In ActiveRecord:
query = Article.where(title: 'ABC') query.find_or_create_by(title: 'XYZ', text: 'something') => #<Article id: 4, title: "XYZ", text: "something"
In Mongoid:
query = Article.where(title: 'ABC') query.find_or_create_by(title: 'XYZ', text: 'something') => #<Article _id: ...., title: "ABC", text: "something"> # title should be 'XYZ'
- is related to
-
MONGOID-3944 Feature Request: #create_with
- Closed