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
Twiz T
12,588 PointsNo way it's a typo
Completing the code challenge for -
Create a new UserFriendship instance variable set to user_friendship with the user set to the current_user and the friend set to the @friend instance variable.
Here's my code and I checked it against the corresponding video but still getting an error, What am I missing here?
def new
if params[:friend_id]
@friend = User.find(params[:friend_id])
@user_friendship = current_user.user_friendships.new(friend: @friend)
else
flash[:error] = "Need friend ID!!"
end
end
ok, so create a new UserFriendship instance variable. Done- @user_friendship =
set to users_friendship with the user set to current_user . Done- current_user.user_friendships.new
and the friend set to to the @friend instance variable. Done- (friend: @friend)
Fresh eyes?
3 Answers
Twiz T
12,588 PointsFor anyone else wondering- http://teamtreehouse.com/forum/create-a-new-userfriendship-instance-variable-set-to-userfriendship-with-the-user-set-to-the-currentuser-and-the-friend-set-to-the-friend-instance-variable
Basically @user_friendships = UserFriendship.new(user: current_user, friend: @friend)
In the video there is user_friendship which maybe isn't agreeing with the code challenge.
Gabe Med
7,457 Pointsthanks tony been having the same questions you had.
I dropped the s on @user_friendships
@user_friendship = UserFriendship.new(user: current_user, friend: @friend)
Twiz T
12,588 PointsBetter formatting for 2nd part.
ok, so create a new UserFriendship instance variable. Done- @user_friendship =
set to users_friendship with the user set to current_user . Done current_user.user_friendships.new
and the friend set to to the @friend instance variable. Done- (friend: @friend)
Rex Suter
8,916 PointsRex Suter
8,916 PointsHey, nitpicking but @user_friendship should be singular sans s, other than that passes!