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

General Discussion

Redirect to the profile_path of the friend.

My code in the 3rd code challenge doesn't seem to be passing and I'm not sure how to have it pass.

http://teamtreehouse.com/library/programming/building-social-features-in-ruby-on-rails/building-the-friendship-ui/saving-models-and-redirecting

Here is what I have:

class UserFriendshipsController < ApplicationController
  def create
    @user_friendship = UserFriendship.new(params[:user_friendship])
    if @user_friendship.save
          flash[:success] = "Friendship created."
          redirect_to profile_path(@friend)
    else
          flash[:error] = "There was a problem."
          redirect_to root_path
    end
  end
end

3 Answers

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey Jim Shook your code is correct. There's a small issue with the code challenge engine which is being worked on now. Sorry about that!

Is this still being worked on? I am having the same issue...

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

This should be working now. Just a heads-up, Jim Shook you can put the redirect at the end of the if/else block and remove the redirect_to root_path if there was an error. That will make the code challenge pass.

Seems like something is up with the engine again? Can't get else flash[:error] = "There was a problem." redirect_to root_path end end end

to pass the final step.

Nevermind. got it to pass w/ redirect_to profile_path(@friend).

Cool thanks Jason :)