-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
mongoid-3.1.3, email and password fields in the following examples are required.
user = User.where(email: 'user1@example.com').first_or_create do |u|
u.password = '12345678'
end
Expected user.persisted? to be true
Got false
Raising validation error when using with a bang:
Mongoid::Errors::Validations:
Problem:
Validation of Referrer failed.
Summary:
The following errors were found: Password can't be blank
Resolution:
Try persisting the document with valid data or remove the validations.
While the following works as expected:
r = User.create do |u|
u.email = 'user1@example.com'
u.password = '12345678'
end
User.where(email: 'user1@example.com').first_or_create(password: '12345678')