In the page http://www.aidanf.net/rails_user_authentication_tutorial there is this model: def login if request.post? if session[:user] = User.authenticate(params[:user][:login], params[:user][:password]) flash[:message] = "Login successful" redirect_to_stored else flash[:warning] = "Login unsuccessful" end end end I understand how the user comes from login form to this if session is not set, but what is User and User.authenticate? Is that a method in ''digest/sha1''? Btw, why does an input field in Rails have a name and an id – besides being able to fun dhtml stuff? Is that somehow connected to User above (sorry for a possibly stupid question)? -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> In the page http://www.aidanf.net/rails_user_authentication_tutorial > there is this model:I mean method. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2006-Aug-23 13:25 UTC
[Rails] Re: What''s user in this method?
Hi -- On Wed, 23 Aug 2006, Pl Bergstrm wrote:> > Pl Bergstrm wrote: >> In the page http://www.aidanf.net/rails_user_authentication_tutorial >> there is this model: > > I mean method.I think it''s your subconscious at work: User is in fact a model :-) More technically, it''s the name of a class, and User.authenticate is one of its class methods. You''ll find it, in all likelihood, in app/models/user.rb. David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <----- http://dablog.rubypal.com => D[avid ]A[. ]B[lack''s][ Web]log http://www.manning.com/black => book, Ruby for Rails http://www.rubycentral.org => Ruby Central, Inc. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> I understand how the user comes from login form to this if session is > not set, but what is User and User.authenticate? Is that a method in > ''digest/sha1''?Think I got the User. Coming from the table in the db and model, right? -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
In that tutorial, the author first goes over creating the User model. In the code snippet you identify, he is calling the authenticate method of that User model (the User model code listing on that page lists the authenticate method). As to input fields having an id and a name... see the W3C for detailed explanations of the id (http://www.w3.org/TR/html4/struct/global.html#adef-id) and name (http://www.w3.org/TR/html4/interact/forms.html#h-17.4) attributes. c. Pål Bergström wrote:> In the page http://www.aidanf.net/rails_user_authentication_tutorial > there is this model: > > def login > if request.post? > if session[:user] = User.authenticate(params[:user][:login], > params[:user][:password]) > flash[:message] = "Login successful" > redirect_to_stored > else > flash[:warning] = "Login unsuccessful" > end > end > end > > I understand how the user comes from login form to this if session is > not set, but what is User and User.authenticate? Is that a method in > ''digest/sha1''? > > Btw, why does an input field in Rails have a name and an id – besides > being able to fun dhtml stuff? Is that somehow connected to User above > (sorry for a possibly stupid question)?-- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Cayce Balara wrote:> In that tutorial, the author first goes over creating the User model. In > the code snippet you identify, he is calling the authenticate method of > that User model (the User model code listing on that page lists the > authenticate method).Thanks Cayce. That helps.> As to input fields having an id and a name... see the W3C for detailed > explanations of the id > (http://www.w3.org/TR/html4/struct/global.html#adef-id) and name > (http://www.w3.org/TR/html4/interact/forms.html#h-17.4) attributes.Id is something I use a lot, and know about. I was just wondering why Rails uses it the way it does, besides being able to make it disappear on fly, if you want. :-) -- 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 -~----------~----~----~----~------~----~------~--~---