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 trialNelly Nelly
7,134 PointsStuck on challenge task 2 of 3 Set the flash error message to "There was a problem." if the @user_friendship is not s
I have this "Bummer! There was no flash error message." with that code? What 's wrong? thanks for your help :)
class UserFriendshipsController < ApplicationController
def create
if
@user_friendship = current_user.user_friendships.new(friend: @friend)
@user_friendship.save
flash[:success] = "Friendship created."
else
flash[:error] ="There was a problem."
end
end
end
5 Answers
Ilya Dolgirev
35,375 PointsYou have to look carefully on your code :) You've just misplaced assignment with condition. Generally, you need to assign a variable first (move it outside from condition block), then check the condition about successful saving.
I don't want to place the correct code right now, but if you still stuck let me know.
Ilya Dolgirev
35,375 PointsWhat the error message? :)
Nelly Nelly
7,134 Pointsit said Bummer! No redirect occurred. :(
Ilya Dolgirev
35,375 PointsThe challenge said to just redirect to friend's profile, no matter you successfully save your friendship or not.
Nelly Nelly
7,134 PointsOKay got it.... it ! passed the redirect_to after condition!
Thanks for your help ! Very intersting way to help!
I can be happy that I kinda found myself
Ilya Dolgirev
35,375 PointsYou're welcome :) IMHO, it's the best way to get something when you do it yourself even you get some tips. So, you can be proud! :) Good luck!
Nelly Nelly
7,134 Pointsthanks ! I may have other question in the futur
Nelly Nelly
7,134 PointsNelly Nelly
7,134 Pointsalmost got it now iam stuck on thrid question
Redirect to the profile_path of the friend.