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

UserFriendshipTest still fails

After adding should belong_to(:user) to user_friendship_test.rb and belongs_to :user to user_friendship.rb, I still get a failure.

1) Failure:
test: UserFriendship should belong to user. (UserFriendshipTest)      [/usr/local/rvm/gems/ruby-1.9.3-    p392/gems/shoulda-context-1.0.2/lib/shoulda/context/context.rb:332]:
Expected UserFriendship to have a belongs_to association called user (UserFriendship does not have a    user_id foreign key.)

I have this in my create_user_friendships.rb also:

class CreateUserFriendships < ActiveRecord::Migration
  def change
    create_table :user_friendships do |t|
      t.integer :user_id
      t.integer :friend_id
      t.timestamps
    end

    add_index :user_friendships, [:user_id, :friend_id]
  end
end

1 Answer

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hi Charles Tobias

What does your UserFriendship model look like? You can find it in app/models/user_friendship.rb.

Thank you for responding. I had some misalignments in my database so I reset the database and everything works fine now