Displaying 5 results from an estimated 5 matches for "has_password".
Did you mean:
hash_password
2011 May 06
3
Why returns nil?
Hi everyone, I''d like some help to understand this method:
def self.authenticate(email, submitted_password)
user = find_by_email(email)
return nil if user.nil?
return user if user.has_password?(submitted_password)
# Don''t understand why it doesn''t return user instead of nil
# since ''user = find_by_email(email)'' was the last evaluated expression
end
like the comment, I just don''t get it, if anyone could explain it to me,
please do it...
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
...: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-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org", "foobar")...
2011 Jul 19
0
Ruby on Rails Tutorial Chapter 8 Signup Success
...email_regex},
:uniqueness => {:case_sensitive => false}
validates :password, :presence => true,
:confirmation => true,
:length => {:within => 6..40}
before_save :encrypt_password
def has_password?(submitted_password)
encrypted_password == encrypt(submitted_password)
end
class << self
def authenticate(email, submitted_password)
user = User.find_by_email(email)
return nil if user.nil?
return user if user.has_password?(submitted_...
2012 Feb 03
10
ruby on rails 3 tutorial book chapter9 Signin Failure
Hi I have problem trying to pass the signin failure test.
This is the test code of the sessions_controller.rb
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render
2005 Apr 23
7
Validation question
Hi all,
Is there a way to invoke validations at times other than save, create
and update? I know that I can do this by writing my own validation
checks using errors.add_[blah], but I''d like to leverage the existing
validation code.
What I have is two sets of fields in a record, set A and set B. Both
sets must be validated on record create. However, the trouble is that
after