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 Building Social Features in Ruby on Rails Building the Friendship UI Saving Models and Redirecting

Ruby code challenge troubles

I'm having a lot of difficulty passing this challenge. The task I'm having trouble with is the first task in the attached challenge. It's to the point where I've gone back and looked at the video and pretty much copied Jason's code word-for-word, so I must be missing a ton here. Can anyone help me?

class UserFriendshipsController < ApplicationController
  def create
    if params[:user_friendship] && params[:user_friendship].has_key?(:friend_id)
      @friend = User.where(profile_name: params[:user_friendship][:friend_id]).first
      @user_friendship = current_user.user_friendships.new(friend: @friend)
      @user_friendship.save
      flash[:success] = "Friendship created."
    end
  end
end

Thanks in advance!

I'm having the same problem. Did you find a solution or just decide to skip over it?

No, I wasn't able to solve it.