Dynamic find_by method returning nil in a class method

I have a user Model with a class method that I am using to do some
authentication

basically something like this

class User < ActiveRecord::Base

  attr_accessor :password
  attr_accessible :first_name, :last_name,
                  :email, :birth_date, :sex,
                  :password, :password_confirmation

  email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

  validates :first_name, :presence => true,
                          :length => { :maximum => 50 }

  validates :last_name, :presence => true,
                          :length => {:maximum => 50 }

  validates :email, :presence => true,
                          :format => { :with => email_regex },
                          :uniqueness => { :case_sensitive =>
false }

  validates :password, :presence => true,
                          :length => {:within => 6..20},
                          :confirmation => true

  validates :sex, :presence => true

  validates :birth_date, :presence => true

  def self.authenticate(email, submitted_password)
    user = find_by_email(email)
    puts user
    return nil if user.nil?
    return user if user.has_password?(submitted_password)
  end

end

as you can see I left out some code but the problem I am having is
where you can see that I have a "puts user". when running this method
from the Console like so

User.authenticate("my@email.com", "foobar") the local user object in
the authenticate method returns nil from the puts

now in the console if I do this

User.find_by_email("my@email.com") the consol returns me a valid user
object from the database

what am I missing here ?

thanks in advance for any insight you can offer.

Try using user = self.find_by_email(email)

Try this one

user = self.find_by_email(email)