MarcS
2007-Dec-20 16:43 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2007-Dec-20 20:03 UTC
Re: problem when empty string is being passed to update_attributes
raise Exception, "Password is blank" if params[:user][:password].blank? || params[:password_confirmation].blank? On Dec 21, 2007 3:13 AM, MarcS <marcschuetze-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MarcS
2007-Dec-20 20:56 UTC
Re: problem when empty string is being passed to update_attributes
thanks On Dec 20, 9:03 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> raise Exception, "Password is blank" if params[:user][:password].blank? || > params[:password_confirmation].blank? > > On Dec 21, 2007 3:13 AM, MarcS <marcschue...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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 > > -- > Ryan Bigghttp://www.frozenplague.net--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---