Problem when empty string is being passed to update_attributes

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

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

On Dec 21, 2007 3:13 AM, MarcS [email protected] 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.
http://www.frozenplague.net

thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs