Forum: Ruby on Rails Update only selected columns

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C01f0b3db2e2548c7fd7de4052302925?d=identicon&s=25 Ian (Guest)
on 2008-10-07 23:05
(Received via mailing list)
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?
23e4fc3add5443f51e55663cfc245d24?d=identicon&s=25 Erol Fornoles (Guest)
on 2008-10-08 03:24
(Received via mailing list)
On Oct 8, 5:04 am, Ian <ian.2...@yahoo.com> 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.
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-10-08 19:03
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?
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-10-08 19:05
> Either provide a change password page, or a separate for used
Sorry I meant to say a separate form on the same page.
This topic is locked and can not be replied to.