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 Managing Friendships Scoped Finders

Marissa Richardson
Marissa Richardson
47,542 Points

How do you solve the first half of this challenge? My code is identical to the video, but nothing seems to be working.

I've already read some clues that beat around the bush, and I have tried looking at documentation.

user_friendships_controller.rb
class UserFriendshipsController < ApplicationController
  # Write your code here
  def index
    case params[:list]
    when 'pending'
     @user_friendships = current_user.pending_user_friendships.all
    end
  end
end
Marissa Richardson
Marissa Richardson
47,542 Points

I've been told to keep it simple for the first challenge and to only change one part, but this code still fails:

class UserFriendshipsController < ApplicationController
  # Write your code here
  def index
    @user_friendships = current_user.pending_user_friendships.all
  end

end
Marissa Richardson
Marissa Richardson
47,542 Points

Bravo to Jason for his dogged determination! Thanks so much.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Marissa,

I am also struggling to figure why this code is incorrect (posted in this thread).

If you've solved this, can you please share, because I'm at a loss.

:dizzy:

Marissa Richardson
Marissa Richardson
47,542 Points

I haven't solved it yet, and I have tried many times. I have checked all over the internet, and I'm just not finding anything to suggest that 'current_user.pending_user_friendships.all' is wrong. It's the opposite in fact. And I mean I checked everywhere, including the GitHub repo and several StackOverflow questions and answers. There's no clear cut documentation to reference for this problem, and it has ended up wasting a lot of my time. Some are speculating that the answers were changed to be impossible to solve. Don't let that discourage you from other Ruby and Rails courses though.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Thanks Marissa,

I, too, have searched for hours and have come to the same conclusion - that what we have is correct.

I have contacted the support team and they are forwarding this to the teachers, so hopefully, some light will be shed on this very soon.

:)

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hey Marissa Richardson,

Jay McGavren is the new Ruby Teacher for Treehouse. He fixed a bug that was in the code challenge. Everything is good now and both tasks pass.

The code block you posted where you "keep it simple" is the correct code for task one, and it will now pass.

:smiley: