Hey people,
I was wondering how to solve the following problem...
I have a login system which uses MD5 + salts to store my users passwords
in the database. Also I am working with profiles for my users which they
can change.
Everything goes quite okay except when we reach the change_profile bit
of the application. Because the user model has validations it performs
on the password it starts throwing error when a user views the
change_profile page. The errors are there as soon as the page is loaded,
even before the form gets submitted.
3 errors prohibited this candidate from being saved
There were problems with the following fields:
* Password confirmation can''t be blank
* Password can''t be blank
* Password is too short (minimum is 4 characters)
Is there a way to stop the model from using it''s password validations
whenever a user is changing his profile? I tried to exclude the password
fields from the change_profile form, but this still generates the same
errors...
Thanks in advance,
Danny
--
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
-~----------~----~----~----~------~----~------~--~---
Hi Danny, Daniel Owen van Dommelen wrote:> Because the user model has validations it performs > on the password it starts throwing error when a user > views the change_profile page. The errors are there > as soon as the page is loaded, even before the form > gets submitted. > > 3 errors prohibited this candidate from being saved > > Is there a way to stop the model from using it''s password > validations whenever a user is changing his profile?Sorry to be dense, but I''m not getting a clear picture here and need to ask a couple of questions. Is the password stored in the User model? Is the profile part of the User model? Validations get run on three events: create, update, and save. You must be doing one of those to get the errors you''re getting. Which doesn''t make sense given your description of the situation. Or maybe I just haven''t gotten enough caffine into the system yet ;-) At any rate, you can specify which event(s) trigger the validation(s) in your validate methods. Check the ActiveRecord::Validations::ClassMethods documentation at http://api.rubyonrails.org/ hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Hi Danny, > > Daniel Owen van Dommelen wrote: > >> Because the user model has validations it performs >> on the password it starts throwing error when a user >> views the change_profile page. The errors are there >> as soon as the page is loaded, even before the form >> gets submitted. >> >> 3 errors prohibited this candidate from being saved >> >> Is there a way to stop the model from using it''s password >> validations whenever a user is changing his profile? > > Sorry to be dense, but I''m not getting a clear picture here and need to > ask > a couple of questions. Is the password stored in the User model? Is > the > profile part of the User model? Validations get run on three events: > create, update, and save. You must be doing one of those to get the > errors > you''re getting. Which doesn''t make sense given your description of the > situation. Or maybe I just haven''t gotten enough caffine into the > system > yet ;-) At any rate, you can specify which event(s) trigger the > validation(s) in your validate methods. Check the > ActiveRecord::Validations::ClassMethods documentation at > http://api.rubyonrails.org/ > > hth, > BillHey, thanks for replying... I believe one of the members on our team has already resolved the problem. The problem was pretty complex and at the moment I just do not have the time to completely detail it for you... Anyways, thanks again for replying, you''ll probably see me back here ;) Ow and about the coffee, I guess that must be one of the reasons for basically everything, goigng to "the machine" right now myself... -- 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 -~----------~----~----~----~------~----~------~--~---