well, here I am again :) validates_confirmation_of is not working heres my model class User < ActiveRecord::Base attr_accessor :password attr_accessible :email, :first_name, :last_name, :screen_name, :password validates_confirmation_of :password validates_presence_of :email, :first_name, :last_name, :screen_name, :password validates_format_of(:email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :on => :create, :message=>"has an invalid format") #validates the uniqueness of email and screen name validates_uniqueness_of :email, :screen_name #end def before_create logger.info("password set to:"+password) salt = [Array.new(6) {rand(256).chr}.join].pack("m").chomp self.password_salt, self.password_hash salt, Digest::SHA256.hexdigest(password+salt) end #Authenticate a user def self.authenticate(email, password) user = User.find(:first, :conditions => [''email = ?'', email]) if user.blank? || Digest::SHA256.hexdigest(password+ user.password_salt) !user.password_hash raise "UserName or password invalid" end user end end and my view <p><label for="email">Email</label><br/> <%= text_field ''user'', ''email'' %></p> <p><label for="screen_name">Screen Name</label><br/> <%= text_field ''user'', ''screen_name'' %></p> <p><label for="first_name">First Name</label><br/> <%= text_field ''user'', ''first_name'' %></p> <p><label for="last_name">Last Name</label><br/> <%= text_field ''user'', ''last_name'' %></p> <p><label for="password">Password</label><br/> <%= password_field ''user'', ''password'' %></p> <p><label for="password_confirmation">Password Confirmation</label><br/> <%= password_field ''user'', ''password_confirmation''%></p> however if I set differnt passwords in user creation it let me save the 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 -~----------~----~----~----~------~----~------~--~---
J. mp wrote:> well, here I am again :) > > validates_confirmation_of is not working> <%= password_field ''user'', ''password'' %></p> > > <p><label for="password_confirmation">Password Confirmation</label><br/> > <%= password_field ''user'', ''password_confirmation''%></p> >just to add a logger info Parameters: {"user"=>{"password_confirmation"=>"12922eddsd", "screen_name"=>"kdskdk", "first_name"=>"kdskk", "last_name"=>"dskkd", "password"=>"skdks", "email"=>"asdasd-jhk7CmHthq9goHlPtYpdqQ@public.gmane.org"}, "commit"=>"Create", "action"=>"add_user", "controller"=>"admin/user"} it is the the request, but not working :( -- 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 -~----------~----~----~----~------~----~------~--~---
J. mp wrote:> J. mp wrote: >> well, here I am again :) >> >> validates_confirmation_of is not working > >> <%= password_field ''user'', ''password'' %></p> >> >> <p><label for="password_confirmation">Password Confirmation</label><br/> >> <%= password_field ''user'', ''password_confirmation''%></p> >> > just to add a logger info > > Parameters: {"user"=>{"password_confirmation"=>"12922eddsd", > "screen_name"=>"kdskdk", "first_name"=>"kdskk", "last_name"=>"dskkd", > "password"=>"skdks", "email"=>"asdasd-jhk7CmHthq9goHlPtYpdqQ@public.gmane.org"}, "commit"=>"Create", > "action"=>"add_user", "controller"=>"admin/user"} > > it is the the request, but not working :(thanks all, found the problem :) and the solution: attr_accessible :email, :first_name, :last_name, :screen_name, :password,:password_confirmation missedthe password_conmfirmation on attr_accessible list :) -- 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Feb-11 00:40 UTC
Re: validates_confirmation_of not working - now in right place
On Sun, 11 Feb 2007, J. mp wrote:> > well, here I am again :) > > validates_confirmation_of is not workingWhat does the code look like where you create the new user record? David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Feb-11 00:42 UTC
Re: validates_confirmation_of not working - now in right place
On Sat, 10 Feb 2007, dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org wrote:> > On Sun, 11 Feb 2007, J. mp wrote: > >> >> well, here I am again :) >> >> validates_confirmation_of is not working > > What does the code look like where you create the new user record?Never mind -- I just saw that you found the problem :-) David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
unknown wrote:> On Sun, 11 Feb 2007, J. mp wrote: > >> >> well, here I am again :) >> >> validates_confirmation_of is not working > > What does the code look like where you create the new user record? > > > David > > -- > Q. What is THE Ruby book for Rails developers? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com)thanks David but I already realized the problem: missed the password_conmfirmation on attr_accessible list :) -- 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 -~----------~----~----~----~------~----~------~--~---