What's user in this method?

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)?

Pål Bergström wrote:

In the page http://www.aidanf.net/rails_user_authentication_tutorial
there is this model:

I mean method.

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?

Cayce B. 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. :slight_smile:

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)?