is there any special requirement for validates_confirmation_of ? I am trying to make sure 2 passwords are equal (cleanly the rails way).. In my view i have two fields with id user[password] and user[password_confirmation]. in the model i have validates_confirmation_of :password, :message =>"Passwords do not match " Am i missing something here ? thanks adam
This is what I have and works good in my view <%= text_field "user", "password"%> <%= text_field "user", "password_confirmation"%> and in my model validates_confirmation_of :password and in controller def register if request.method == :post @user = User.new(params[:user]) if @user.save session[:user] = @user redirect_to :controller => "mynerve" end else @user = User.new end end So what exactly does not work? Regards Gokhan Arli www.sylow.net -- Posted via http://www.ruby-forum.com/.
if i put in 2 different passwords it just continues without an error. I cant figure out why. adam On 1/20/06, Gokhan Arli <gokhan@sylow.net> wrote:> This is what I have and works good > > in my view > <%= text_field "user", "password"%> > <%= text_field "user", "password_confirmation"%> > > and in my model > validates_confirmation_of :password > > and in controller > > def register > if request.method == :post > @user = User.new(params[:user]) > if @user.save > session[:user] = @user > redirect_to :controller => "mynerve" > end > else > @user = User.new > end > end > > > So what exactly does not work? > > Regards > Gokhan Arli > www.sylow.net > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I''m having the same problem Adam Denenberg wrote:> if i put in 2 different passwords it just continues without an error. > I cant figure out why. > > adam-- Posted via http://www.ruby-forum.com/.
In your model, add this: validates_confirmation_of :password (assuming your column is named password) In your view.rhtml: (assuming your model is named user) <%= password_field ''user'', ''password'' %> <%= password_field ''user'', ''password_confirmation'' %> If you have it like this, then something else is funky. Bob Silva http://www.railtie.net/> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > bounces@lists.rubyonrails.org] On Behalf Of Boram Yoon > Sent: Saturday, January 28, 2006 5:22 PM > To: rails@lists.rubyonrails.org > Subject: [Rails] Re: Re: validates_confirmation_of not working > > I''m having the same problem > > Adam Denenberg wrote: > > if i put in 2 different passwords it just continues without an error. > > I cant figure out why. > > > > adam > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Boram Yoon
2006-Jan-29 02:28 UTC
[Rails] RE: Re: Re: validates_confirmation_of not working
Well, I''m storing hashing and storing the password in the hashed_password column just like the Depot application in the Agile book. And since validates_confirmation_of is only checking :password against :password_confirmation, this should be strictly a naming problem, right? Bob Silva wrote:> In your model, add this: > > validates_confirmation_of :password (assuming your column is named > password) > > > In your view.rhtml: (assuming your model is named user) > > <%= password_field ''user'', ''password'' %> > <%= password_field ''user'', ''password_confirmation'' %> > > If you have it like this, then something else is funky. > > Bob Silva > http://www.railtie.net/-- Posted via http://www.ruby-forum.com/.
Boram Yoon
2006-Jan-29 02:30 UTC
[Rails] RE: Re: Re: validates_confirmation_of not working
Sorry, that first sentence should read "Well, I''m hashing and storing the password in the hashed_password column just like the Depot application in the Agile book." -- Posted via http://www.ruby-forum.com/.
Does your model have ''password'' as an attribute since its not in the table? attr :password And don''t forget to protect your attributes. attr_protected :hashed_password Bob Silva http://www.railtie.net/> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > bounces@lists.rubyonrails.org] On Behalf Of Boram Yoon > Sent: Saturday, January 28, 2006 6:30 PM > To: rails@lists.rubyonrails.org > Subject: [Rails] RE: Re: Re: validates_confirmation_of not working > > Sorry, that first sentence should read > > "Well, I''m hashing and storing the password in the > hashed_password column just like the Depot application in the Agile > book." > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Adam Denenberg
2006-Jan-29 04:32 UTC
[Rails] RE: Re: Re: validates_confirmation_of not working
the issue i had was not following the rails standard in the views. Once i changed everything to the <%= text_field ''user'' , ''password'' %> setup so everything got passed in as @params[:user] it worked ok. The issue was i was just submitting it as @params[:password] originally and not @params[:user]["password"] adam On 1/28/06, Bob Silva <me@bobsilva.com> wrote:> Does your model have ''password'' as an attribute since its not in the table? > > attr :password > > And don''t forget to protect your attributes. > > attr_protected :hashed_password > > > Bob Silva > http://www.railtie.net/ > > > -----Original Message----- > > From: rails-bounces@lists.rubyonrails.org [mailto:rails- > > bounces@lists.rubyonrails.org] On Behalf Of Boram Yoon > > Sent: Saturday, January 28, 2006 6:30 PM > > To: rails@lists.rubyonrails.org > > Subject: [Rails] RE: Re: Re: validates_confirmation_of not working > > > > Sorry, that first sentence should read > > > > "Well, I''m hashing and storing the password in the > > hashed_password column just like the Depot application in the Agile > > book." > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >