Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGraham Grochowski
4,676 Pointsundefined method `authenticate' for nil:NilClass
Ive spent probably an hour fiddling around with my code and cannot for the life of me figure out why this test wont pass.
Ive uploaded this as a github repo https://github.com/ggrochow/odot
Errors im getting
) UserSessionsController POST 'create' with correct credentials redirects to the todo list path
Failure/Error: post :create, email: "jason@teamtreehouse.com", password: "treehouse1"
NoMethodError:
undefined method `authenticate' for nil:NilClass
# ./app/controllers/user_sessions_controller.rb:7:in `create'
# ./spec/controllers/user_sessions_controller_spec.rb:22:in `block (4 levels) in <top (required)>'
1 Answer
Seth Reece
32,867 PointsYour code looks fine to me. Could be your bcrypt-ruby gem, or maybe a typo in your user controller for has_secure_password? Is your project in workspaces to be forked, or on github?
Graham Grochowski
4,676 PointsGraham Grochowski
4,676 PointsSee github
Seth Reece
32,867 PointsSeth Reece
32,867 PointsHmm.. everything still looks fine. I assume you wouldn't have gotten this far without having the bcrypt gem installed.
Graham Grochowski
4,676 PointsGraham Grochowski
4,676 Pointshttps://github.com/ggrochow/odot Uploaded my project files so far up to github, appreciate the help so far. Everything's been working fine up to this point, and i've been able to google around and figure out any other errors ive had, this ones stumped me though.
Seth Reece
32,867 PointsSeth Reece
32,867 PointsIt appears that the ! at the end of self.email = email.downcase is preventing the email address from saving in the database. The user tests pass because it is sending in the right information.
but the SQL that runs is
Removing the ! gets the email to save but still not getting a passing test. It's my understanding that rspec creates new data each time you test, so it should be creating a new user with id 1 each time. User sessions are being created just fine now.
Must be something in the test now. I've checked for typos and errors, but looks good. I'm out of time today. Update me if you find anything.
Graham Grochowski
4,676 PointsGraham Grochowski
4,676 Pointsthank you so much, explains why I couldn't figure out what was going wrong, I was thinking you could avoid using a = in that step by just doing self.email.downcase! and didn't take it out when I followed what the instructor did