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

Code challenge :Creating Friendship question

In this code challenge 3/3 : http://teamtreehouse.com/library/building-social-features-in-ruby-on-rails-2/creating-friendships/creating-a-has-many-through-association

My code just won't pass, could someone enlighten me ?

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

end

3 Answers

John Steer-Fowler
PLUS
John Steer-Fowler
Courses Plus Student 11,734 Points

Hey Natacha,

Your code is 99% correct. Be careful though, when making the last association, you need to separate through: and :user_friendships

Take a look at my code:

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

This should pass for you

Hope this helps

So close think about spaces

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

Also don't suppose you have any insight into my Rails question just posted in forum :)

Oh jeez, it was just a matter of spaces ! Thanks a lot for your help! @Adam : I'll see if i can help ...

Yup. Put it down to tired eyes lol :)