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

Ruby

(Help) 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.

I have problems with my last assignment/code challenge in the current Ruby section, I have completed nearly all of the other tasks, but cannot find my mistake.

Do you know what is wrong here? I suppose the mistake is in this line, because all the other lines where correct: @user_friendship = current_user.user_friendships.new(friend: @friend)


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

Would be thankful if somebody knows the answer and could explain it to me! Daniel

1 Answer