Displaying 4 results from an estimated 4 matches for "submitted_password".
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
...s :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 th...
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
e...
2011 Jul 19
0
Ruby on Rails Tutorial Chapter 8 Signup Success
...: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_password)
en...
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