Hi Guys,

I'm experimenting with my first rails app currently.  One thing I'm
trying to implement is a login system.

I created a model for user.rb  I've added a couple of functions to the
class for example:

def self.authenticate(user_info)
   find_by_username_and_password(....,
self.hashed_password(user_info[:password]))
end

def self.hashed_password(password)
  Digest::SHA2.hexdigest(password)
end

So from user.rb function self.authenticate I can call
self.hashed_password and it works fine.

>From another file (user_controller.rb) I try to create a new user
based on the authentication parameters, and then call authenticate on
that user.   In order to do that I have to call
user_into.class.authenticate instead of user_info.authenticate...

I don't understand what is going on here with def self.{function} and
the .class modifier.

Can someone point to me somewhere to explain? I have a feeling I'm
doing something wrong but I don't understand what.

Thanks

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to