# Update only selected columns

**URL:** <https://www.ruby-forum.com/t/update-only-selected-columns/150377>\
**Category:** Rails\
**Created:** [October 7, 2008, 11:05pm UTC](https://www.ruby-forum.com/t/update-only-selected-columns/150377 "2008-10-07T23:05:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [October 7, 2008, 11:05pm UTC](https://www.ruby-forum.com/t/update-only-selected-columns/150377/1 "2008-10-07T23:05:48Z")

</div>

I’m working on an “update your profile” page. One of the fields is  
the user’s password. I have a couple of validation rules set up in  
the user model regarding the password’s minimum and maximum length and  
it not being blank, etc. They work great. However, is there a way to  
turn them off and not update that column if the user does not enter  
anything in that field?

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [October 8, 2008, 3:24am UTC](https://www.ruby-forum.com/t/update-only-selected-columns/150377/2 "2008-10-08T03:24:47Z")

</div>

On Oct 8, 5:04 am, Ian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m working on an “update your profile” page. One of the fields is  
> the user’s password. I have a couple of validation rules set up in  
> the user model regarding the password’s minimum and maximum length and  
> it not being blank, etc. They work great. However, is there a way to  
> turn them off and not update that column if the user does not enter  
> anything in that field?

You could pass :unless if you’re using the validation helpers.

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [October 8, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/update-only-selected-columns/150377/3 "2008-10-08T19:03:44Z")

</div>

This is a common issue, and not with just Rails applications. You best  
bet is to design your user profile update page to not send the password.  
Either provide a change password page, or a separate for used  
specifically to change the password.

Others may have other ideas on how to deal with that. I suggest looking  
around at other profile update pages and see how they handle it.

Ian wrote:

> I’m working on an “update your profile” page. One of the fields is  
> the user’s password. I have a couple of validation rules set up in  
> the user model regarding the password’s minimum and maximum length and  
> it not being blank, etc. They work great. However, is there a way to  
> turn them off and not update that column if the user does not enter  
> anything in that field?

---

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [October 8, 2008, 7:05pm UTC](https://www.ruby-forum.com/t/update-only-selected-columns/150377/4 "2008-10-08T19:05:25Z")

</div>

> Either provide a change password page, or a separate for used  
> Sorry I meant to say a separate form on the same page.
