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

Bruce Canedy
Bruce Canedy
13,496 Points

Issue completing code challenge

Navigation : Building Social Features in Ruby on Rails > Building the Friendship UI > Saving Models and Redirecting

Task: 1/3

i can not get this to pass. Here is the code i'm using. can you please provide some feedback on what i am doing wrong.

i receiving the following error.

Bummer! There was no flash success message set.

challenge code

@user_friendship = current_user
if @user_friendship.save
  flash[:success] = 'Friendship created'
end

3 Answers

Hi Bruce! Thanks for posting :D Mind sending me a screenshot please help@teamtreehouse.com? That'd be super helpful :)

Screenshots will help us see what code challenge your on, what it is asking you exactly, what your answer is, and what the error message or hint says to you when it pops up :) Thanks!

Njeri Chelimo
Njeri Chelimo
6,860 Points

hi Bruce. I'm in the same situation. I've tried all solutions that I can think of. please tell me if you found a solution.

Here is the solution I am pasting in from an earlier post I made:

def create @user_friendship = UserFriendship.new(params[:user_friendship])

if @user_friendship.save

flash[:success] = "Friendship created."

end end end

I think there should be a bit more specificity in instructions for the first line of code. The exact name of the :friend_id association for setting this instance variable is just left to guess work... ironically it was staring at me the whole time, but all the other examples we coded never implied that we should use this logic... and also we didn't know how the data base columns were named going in.

Maybe adding a new step or just giving it to us when we start would have saved some level of headache.

For part three:

redirect_to profile_path(@friend)

Has to be in the "else" clause... I was putting it in the "if" statement like we did in the "Creating the Friendship" video. In the code challenge there is no reason to even create a friend instance variable, even though the line implies one, just be sure on part three to throw the redirect command in the "else" clause.