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 trialMandy Yeung
14,909 PointsUser Authentication with Rails
Can someone help me out with this "Creating a Sessions Controller" quiz question?
Type the method that we would call on the user object to check the submitted password:
user = User.find_by(email: params[:email]) if user && user._______________________
My answer:
user = User.find_by(email: params[:email]) if user && user.authenticate(params[:password])
Thanks!
6 Answers
Jason Seifer
Treehouse Guest TeacherHey all, the correct answer is authenticate
since that is the name of the method. It's a little tricky but we aren't asking for the parameters to the method.
David Curtis
11,301 PointsTry this:
if user && user.authenticate(params[:session][:password])
Stone Preston
42,016 Pointsthat doesnt seem to be working either.
Stone Preston
42,016 PointsThe code snippet from this video suggests your answer is correct.
here is the snippet:
user = User.find(params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to todo_lists_path
else
flash.now[:error] = "There was a problem authenticating."
render action: 'new'
end
any thoughts Jason Seifer ?
Stone Preston
42,016 PointsHmm that looks correct. Can you post a link to the quiz?
Mandy Yeung
14,909 PointsMandy Yeung
14,909 PointsMystery solved! Thanks a lot everyone.