Hi, I have a member registration form which takes a "Name", "Login", "Password", "Confirm Password" and "Location". In the user model I have added the validation validate_uniqueness_of :login, validate_presence_of :password, :name, :confirm_password. When the member tries to register every thing working fine. I am using same form for user to edit his information. When the user come to edit his information we are not allowing the user to edit the password so that we are hiding those fields. But whenever user adds some invalid data suppose he hasn''t added the "name" then the error is shown "Name should not be blank" but with that it also shows that "Password should not be blank". I have checked the post data don''t have the password and confirm password parameter. My controller code is like this:- "@member = User.find(params[:user_id]) @member.update_attributes(params[:user]) " Can anyone have any idea how to solve this? Thanks Tushar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try Some thing like this On updating Yours model Code is validating presence of confirm_password Which should not be i think. validate_uniqueness_of :login validate_presence_of :password, :name, validate_confirmation_of:confirm_password. On Mon, Jun 7, 2010 at 12:19 PM, Tushar Gandhi <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > I have a member registration form which takes a "Name", "Login", > "Password", "Confirm Password" and "Location". In the user model I have > added the validation > validate_uniqueness_of :login, validate_presence_of :password, :name, > :confirm_password. > > When the member tries to register every thing working fine. I am using > same form for user to edit his information. When the user come to edit > his information we are not allowing the user to edit the password so > that we are hiding those fields. > But whenever user adds some invalid data suppose he hasn''t added the > "name" then the error is shown "Name should not be blank" but with that > it also shows that "Password should not be blank". I have checked the > post data don''t have the password and confirm password parameter. My > controller code is like this:- > > "@member = User.find(params[:user_id]) > @member.update_attributes(params[:user]) " > Can anyone have any idea how to solve this? > > Thanks > Tushar > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Rajeev, I just added the model validations for understanding. Whatever model validation you have added are same in my model. Thanks, Tushar -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try this in yours model Validate :password_confirmation def password_confirmation -------------------------------------- -------------------------------------- -----Your Code---------------- -------------------------------------- -------------------------------------- end On Mon, Jun 7, 2010 at 12:48 PM, Tushar Gandhi <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi Rajeev, > I just added the model validations for understanding. > > Whatever model validation you have added are same in my model. > > Thanks, > Tushar > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.