# Update\_attribute and validations

**URL:** <https://www.ruby-forum.com/t/update-attribute-and-validations/52651>\
**Category:** Rails\
**Created:** [January 17, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/update-attribute-and-validations/52651 "2006-01-17T17:16:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![victorgrey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9fc29f/32.png) [@victorgrey](https://www.ruby-forum.com/u/victorgrey)\
**Post date:** [January 17, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/update-attribute-and-validations/52651/1 "2006-01-17T17:16:10Z")

</div>

Just in case it saves someone else the several hours of insanity I just  
went through, update\_attributes will not save unless the model  
validations are satisfied, but update\_attribute (the singular form)  
will save the attribute to the database even if the model validations  
would fail!

This appears to be a feature, not a bug  
([Peak Obsession](http://api.rubyonrails.com/classes/ActiveRecord/Base.html)) although it  
is not mentioned in Agile Web Dev with Rails (page 221).

Regards,  
Victor G.

---

<div class="post-metadata">

**Author:** ![victorgrey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9fc29f/32.png) [@victorgrey](https://www.ruby-forum.com/u/victorgrey)\
**Post date:** [January 17, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/update-attribute-and-validations/52651/2 "2006-01-17T17:28:12Z")

</div>

Wow, that is odd, you would think it would work the same as  
update\_attributes. Or it least there would be a  
update\_attribute(name,value,validate) where validate is a boolean.

---

<div class="post-metadata">

**Author:** ![victorgrey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9fc29f/32.png) [@victorgrey](https://www.ruby-forum.com/u/victorgrey)\
**Post date:** [January 17, 2006, 5:31pm UTC](https://www.ruby-forum.com/t/update-attribute-and-validations/52651/3 "2006-01-17T17:31:13Z")

</div>

On 1/17/06, Paul B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Wow, that is odd, you would think it would work the same as  
> update\_attributes. Or it least there would be a  
> update\_attribute(name,value,validate) where validate is a  
> boolean.

It was made specifically for updating things such as boolean fields.  
If you want to update more fields without validation, you can do this:

@foo.attributes = params[:foo]  
@foo.save(false)

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)
