mongoid/mongoid — Issue #1760: Double save (update_attribute after save) bypasses validations
Author: alex-klepa
Created: 2012-02-25 02:34:26+00:00
State: open

An update_attribute called after save will successfully save invalid fields:

```ruby
class Person
include Mongoid::Document
field :name, :type => String
field :age, :type => Integer

validates_numericality_of :age
end

p = Person.new(:age => 35)
p.save!

p => { "_id" : ObjectId("4f4845e6759b51801a000582"), "age" : 35 }

p.age = "infinity"
if p.save
p.update_attribute(:name, "Alex")
else
p.update_attribute(:name, "Hooligan")
end

p => { "_id" : ObjectId("4f4845e6759b51801a000582"), "age" : "infinity", "name" : "Hooligan" }

```