# Problem when empty string is being passed to update\_attributes

**URL:** <https://www.ruby-forum.com/t/problem-when-empty-string-is-being-passed-to-update-attributes/123792>\
**Category:** Rails\
**Created:** [December 20, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/problem-when-empty-string-is-being-passed-to-update-attributes/123792 "2007-12-20T17:44:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/54ee81/32.png) [@MarcS](https://www.ruby-forum.com/u/MarcS)\
**Post date:** [December 20, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/problem-when-empty-string-is-being-passed-to-update-attributes/123792/1 "2007-12-20T17:44:55Z")

</div>

Hi,

I have the following problem:  
I have a page where users can update their passwords.  
When users just leave the password and password\_confirmation fields  
blank, rails will not raise an error when I do

@user.update\_attributes(params[:user])

Instead, rails will just leave the record as it is.  
My guess is that empty fields in the params[:user] hash are just being  
ingored when calling update\_attributes.  
Any idea how to get around that?  
I’m sure it’s really easy but I have no idea how to fix that

thanks,  
Marc

---

<div class="post-metadata">

**Author:** ![MarcS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/54ee81/32.png) [@MarcS](https://www.ruby-forum.com/u/MarcS)\
**Post date:** [December 20, 2007, 9:04pm UTC](https://www.ruby-forum.com/t/problem-when-empty-string-is-being-passed-to-update-attributes/123792/2 "2007-12-20T21:04:49Z")

</div>

raise Exception, “Password is blank” if params[:user][:password].blank?  
||  
params[:password\_confirmation].blank?

On Dec 21, 2007 3:13 AM, MarcS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Instead, rails will just leave the record as it is.  
> My guess is that empty fields in the params[:user] hash are just being  
> ingored when calling update\_attributes.  
> Any idea how to get around that?  
> I’m sure it’s really easy but I have no idea how to fix that
> 
> thanks,  
> Marc
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![MarcS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/54ee81/32.png) [@MarcS](https://www.ruby-forum.com/u/MarcS)\
**Post date:** [December 20, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/problem-when-empty-string-is-being-passed-to-update-attributes/123792/3 "2007-12-20T21:56:25Z")

</div>

thanks
