I have a simple form to allow the user to update their password. It always throws the error saying that the password is too short (they are over the min of 6 chars). The passwords are making it in to the model just fine. If I raise an exception within the before_validation user method the password and password confirmation values both exist, but it still throws an error. I do have both the pw and pw_conf as attr_accessible in the users model. I am stumped to why it is doing this. Any ideas? def password @user = current_user return if request.get? if @user.update_attributes( :password => params[:password], :password_confirmation => params[:password_confirmation]) flash[:success] = "Your password has been updated." redirect_to admin_user_path(@user) else render :action => :password end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is the form. - form_tag "/admin/users/password" do %fieldset = form_field("Password", :tip => "required") { password_field :password, nil, :size => 15 } = form_field("Password Confirmation", :tip => "required") { password_field :password_confirmation, nil, :size => 15 } .buttons = submit_tag "Save Password" or = link_to "Cancel", admin_user_path(@user) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-13 09:30 UTC
Re: Can anyone see why the pw validation is failing?
On Jan 13, 4:15 am, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Here is the form. > > - form_tag "/admin/users/password" do > %fieldset > = form_field("Password", :tip => "required") { password_field > :password, nil, :size => 15 } > = form_field("Password Confirmation", :tip => "required") { > password_field :password_confirmation, nil, :size => 15 } >Looking at the params that are submitted would probably tell you why. You''re abusing password_field by passing nil as the second argument. You could either use form builders, form for etc... use password_field properly (ie first parameter is the name of an instance variable, 2nd is a method name) or use password_field_tag. Fred> .buttons > = submit_tag "Save Password" > or > = link_to "Cancel", admin_user_path(@user) > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-13 09:33 UTC
Re: Can anyone see why the pw validation is failing?
On Jan 13, 9:30 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 13, 4:15 am, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Here is the form. > > > - form_tag "/admin/users/password" do > > %fieldset > > = form_field("Password", :tip => "required") { password_field > > :password, nil, :size => 15 } > > = form_field("Password Confirmation", :tip => "required") { > > password_field :password_confirmation, nil, :size => 15 } > > Looking at the params that are submitted would probably tell you why. > You''re abusing password_field by passing nil as the second argument. > You could either use form builders, form for etc... use password_field > properly (ie first parameter is the name of an instance variable, 2nd > is a method name) or use password_field_tag.And if you''re lucky enough that rails lets you get away with that, then showing the code that''s actually relevant here (ie the model and its validations) would be useful. Fred> > Fred > > > .buttons > > = submit_tag "Save Password" > > or > > = link_to "Cancel", admin_user_path(@user) > > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Jan 13, 4:15�am, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Here is the form. >> >> - form_tag "/admin/users/password" �do >> � %fieldset >> � � = form_field("Password", :tip => "required") { password_field >> :password, nil, :size => 15 } >> � � = form_field("Password Confirmation", :tip => "required") { >> password_field :password_confirmation, nil, :size => 15 } >> > > Looking at the params that are submitted would probably tell you why. > You''re abusing password_field by passing nil as the second argument. > You could either use form builders, form for etc... use password_field > properly (ie first parameter is the name of an instance variable, 2nd > is a method name) or use password_field_tag. > > FredThat would be it. What threw me was that when debugging things I could see the password and pwc set within the model, both before and after the validation, but it would continue saying that it wasn''t there. Thanks for the help Fred. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---