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 trialRichard Montenegro
9,844 PointsTreebook - Friend_id not saving?
Hey everyone! Im doing the rails project on Building Social Features. I'm trying to create the "Add Friends" feature but it seems that when I click the button it won't save the friend_id. Any suggestions?
2 Answers
Seth Reece
32,867 PointsI think you might need where instead of find. e.g.
def new
if params[:friend_id]
@friend = User.where(params[:friend_id])
@user_friendship = current_user.user_friendship.new(friend: @friend)
else
flash[:error] = "Friend Required"
end
end
Jared Galanis
8,382 PointsWhat error are you getting and does it reference a line of code?
Richard Montenegro
9,844 PointsRichard Montenegro
9,844 PointsHere is my github code (https://github.com/rjent7/conekt/blob/master/app/controllers/user_friendships_controller.rb)