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 trial
Itay Banner
1,922 PointsCode challenge troubles: Finding and Building Models 2/3
I'm having troubles passing this code challenge. I've managed to pass the first stage, but then I got stuck in the 2nd stage, and I can't figure out why.
The task is to "Find the friend specified by the friend_id param and set it to a friend instance variable." My solution was to add this code, which was also used (if I'm not mistaken) in the prior video:
@friend = User.find(params[:friend_id])
I tried to add it as an additional line of code just below the one I wrote to (successfully) pass the 1st stage. I failed (more like errored out - some sort of a message about the code challenges engine crashing - but when refreshed I managed to pass 1st stage again). Then I tried it with the if-else statement that was shown in the video, but also - nothing worked for me.
What am I doing wrong?
EDIT: Of course I passed a minute after posting this. How very Murphy. Anyway, TeamTreeHouse staff - something went bezerk lately in the code challenges module. I used to pass those in the past with no particular problems
3 Answers
Jason Seifer
Treehouse Guest TeacherGreat job Itay! Let us know if you need any more help :)
Naomi Freeman
Treehouse Guest TeacherIt's broken again.
Sergi Beltran
18,493 PointsI can't pass this challenge, this is my code:
class UserFriendshipsController < ApplicationController
def new
unless params[:friend_id].present?
flash[:error] = 'Friend required'
end
@friend = User.find(params[:friend_id])
end
end