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
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 G. [email protected]
wrote:
that we are hiding those fields.
Thanks
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Thanks:
Rajeev sharma
Hi Rajeev,
I just added the model validations for understanding.
Whatever model validation you have added are same in my model.
Thanks,
Tushar
Try this in yours model
Validate :password_confirmation
def password_confirmation
-----Your Code----------------
end
On Mon, Jun 7, 2010 at 12:48 PM, Tushar G. [email protected]
wrote:
–
You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected][email protected]
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Thanks:
Rajeev sharma