Hi all, when my user edit its account - he can leave the password field blank to leave the used password untouched. but he cant leave it blank - because the validation process in my user modell validates the password field all the way and throws of course an error if the user leave it blank. I also have a password_confirmation field that only needs to validat if a password is given. validates_confirmation_of :password validates_presence_of :password I read something from attr_accessor :password but I dont understand the function of this attribute How can I go around this? I am happy for any help thanks Andreas -- 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 -~----------~----~----~----~------~----~------~--~---
Andreas Schneider wrote:> validates_confirmation_of :password > validates_presence_of :passwordtry validates_presence_of :password, :allow_nil => true It''s not in the api doc as it relates to this specific validator, but it''s at the top of this page: http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M000813 -- 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 -~----------~----~----~----~------~----~------~--~---
David Coleman wrote:> try > validates_presence_of :password, :allow_nil => true > > It''s not in the api doc as it relates to this specific validator, but > it''s at the top of this page: > > http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M000813thanks david, but this will not work - I still get the "password can''t be blank" error message also, thus I use the same modell for creating a new user - than I really need the validation - so I cant turn it off I wonder why nobody else ran into that problem andreas -- 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 -~----------~----~----~----~------~----~------~--~---
On 11/6/06, David Coleman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Andreas Schneider wrote: > > validates_confirmation_of :password > > validates_presence_of :password > > > try > validates_presence_of :password, :allow_nil => true > > It''s not in the api doc as it relates to this specific validator, but > it''s at the top of this page: > > http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M000813 >There''s also the :if option, documented in the link above. Isak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
i found a good resource http://www.ruby-forum.com/topic/60002 -- 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 -~----------~----~----~----~------~----~------~--~---
Andreas Schneider wrote:> > thanks david, but this will not work - I still get the "password can''t > be blank" error message > > also, thus I use the same modell for creating a new user - than I really > need the validation - so I cant turn it off > > I wonder why nobody else ran into that problem > > andreasvalidates_presence_of :password, :on => :create -- 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 -~----------~----~----~----~------~----~------~--~---