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!
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

Natacha S
11,561 PointsCode 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
Courses Plus Student 11,734 PointsHey 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

Adam Sackfield
Pro Student 19,663 PointsSo close think about spaces
class User < ActiveRecord::Base
has_many :user_friendships
has_many :friends
has_many :friends, through: :user_friendships
end

Adam Sackfield
Pro Student 19,663 PointsAlso don't suppose you have any insight into my Rails question just posted in forum :)

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

Adam Sackfield
Pro Student 19,663 PointsYup. Put it down to tired eyes lol :)