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 Creating Model Methods

Jason Breitigan
Jason Breitigan
15,074 Points

Creating Model Methods

This is what I have based on the video:

class User < ActiveRecord::Base has_many :user_friendships has_many :friends, through: :user_friendships

has_many :pending_user_friendships, class_name: 'UserFriendship', conditions: { state: 'pending' } has_many :blocked_user_friendships, class_name: 'UserFriendship', conditions: { state: 'blocked' }

has_many :pending_friends, through: :pending_user_friendships has_many :blocked_friends, through: :blocked_user_friendships

def has_blocked?(other_user) blocked_friends.include?(other_user) end

end

I entered it like the video shows but it doesn't pass and the information I gained on another thread about this challenge didn't work for me. Any one have any idea what the deal is with this?

1 Answer

Kang-Kyu Lee
Kang-Kyu Lee
52,045 Points

I just passed after edited from the above, source: :friend at the end of has_many :blocked_friends line. But I don't know why? I tried to find out from documentations, but still not clear. So I am just going to ask our teacher Jason Seifer

Or this might be just a broken part... https://teamtreehouse.com/forum/challenge-task-2-blocked-friends