OMG thank you soooo much!!!
On Feb 3, 12:33 pm, Prince Joseph wrote:
def self.authenticate(email, submitted_password)
user = find_by_email(email)
return nil if user.nil
return user if user.has_password?(summitted_password)
end

Here 'user.nil' in the third line should be 'user.nil?'. There is a typo
('?' missing).








On Fri, Feb 3, 2012 at 10:43 PM, Jean wrote:
No Dave, I copy from my code.  And this is the error:
NoMethodError in SessionsController#create
undefined method `nil' for nil:NilClass
Rails.root: /Users/jeanosorio/rails_projects/sample_app
Application Trace | Framework Trace | Full Trace
app/models/user.rb:37:in `authenticate'
app/controllers/sessions_controller.rb:7:in `create'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"1Dc0iARaC7tLF0Jwp7ZX9XJAOTtqHqavl0+x6qkHlEw=",
"session"=>{"email"=>"",
"password"=>"[FILTERED]"},
"commit"=>"Sign in"}
And this is the code for user model
def self.authenticate(email, submitted_password)
user = find_by_email(email)
return nil if user.nil
return user if user.has_password?(summitted_password)
end
I don't understand what's happen
On Feb 3, 11:56 am, Dave Aronson <googlegroups2d...@davearonson.com>
wrote:
On Fri, Feb 3, 2012 at 11:53, Jean wrote:
if I fill the field with and user and password,
that exist in my db I get the same error.
That also sounds like a forgotten question mark.  Ruby would try to
call it, and fail, either way.
-Dave
--
Dave Aronson:  Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) -- seewww.DaveAronson.com, and blogs atwww.Codosaur.us,
www.Dare2XL.com,www.RecruitingRants.com
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
--
Thanks,
Prince
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 9 of 11 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 3, '12 at 4:37p
activeFeb 3, '12 at 8:30p
posts11
users5
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase