mongoid/mongoid — Issue #1527: Assigning false value in a before_save or before_update callback
Author: lucasas
Created: 2011-12-27 12:06:16+00:00
State: open

Hi guys,

I was trying to assign a false value in a boolean field into a before_save or before_update callback then I got the following error:
``Mongoid::Errors::Callback: translation missing: en.mongoid.errors.messages.callbacks``

Here are my code:

```ruby
class Boy
include Mongoid::Document
field :age, :type => Integer
field :can_drink, :type => Boolean

before_save :set_if_person_can_drink

def set_if_person_can_drink
self.can_drink = self.age > 18
end
end

p = Boy.new :age => 19
p.save! # OK

p1 = Boy.new :age => 16
p1.save! # Mongoid::Errors::Callback: translation missing: mongoid.errors.messages.callbacks

class Girl
include Mongoid::Document
field :age, :type => Integer
field :can_drink, :type => Boolean

before_update :set_if_person_can_drink

def set_if_person_can_drink
self.can_drink = self.age > 18
end
end

p = Girl.create :age => 19
p.age = 20
p.save! #OK

p1 = Girl.create :age => 16
p1.age = 15
p1.save! # Mongoid::Errors::Callback: translation missing: mongoid.errors.messages.callbacks
```

I'm using Mongoid 2.2.2. So if possible, could you please guys, apply this fix in this version?

Thank you