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
Julien Gascard
12,818 PointsBuilding Social Features in RoR : can't solve a code challenge
Hi guys,
The step I can't pass is located right there
Here is the code I've typed so far:
class UserFriendshipsController < ApplicationController
def new
if params[:friend_id]
@friend = User.find(params[:friend_id])
@user_friendship = current_user.user_friendships.new(friend: @friend)
else
flash[:error] = "Friend required"
end
end
end
Since it's the exact same code that the one in my local application, I don't really get what's wrong...
Thanks in advance for your help!
3 Answers
Mike Gabriel
8,402 PointsThe question is asking a bit more specific answer than what you are providing.
class UserFriendshipsController < ApplicationController
def new
if params[:friend_id]
@friend = User.find(params[:friend_id])
@user_friendship =UserFriendship.new(user: current_user, friend: @friend)
else
flash[:error] = "Friend required"
end
end
end
Jason Seifer
Treehouse Guest TeacherGreat answer, Mike!
Julien Gascard
12,818 Points@Mike
Thanks for the reply... I must have been by far too tired, since I haven't seen "the user set to the current_user".
Cheers!