Int. Rails Week 2: Unable to Load Constant Error

I just finished writing the code for Week 2 and I am getting an error when I try to follow another user that reads,

Unable to autoload constant FollowingRelationship, expected ../following_relationship.rb to define it

I’m using Rails 4 and Ruby 2.0.0-p247, I think that might be the problem. But here is a screenshot:

Any ideas? Thanks!

It is expecting that you have a FollowingRelationship class defined in following_relationship.rb but not finding it. Does that class exist there? If so, maybe you have a typo in the file name?

Here’s my User model and FollowingRelationship model:

class User < ActiveRecord::Base
  has_many :shouts

  has_many :followed_user_relationships, 
	foreign_key: :follower_id,
	class_name: 'FollowingRelationship'
  has_many :followed_users, through: :followed_user_relationships

  has_many :follower_relationships, 
	foreign_key: :followed_user_id,
	class_name: 'FollowingRelationship'
  has_many :followers, through: :follower_relationships 
end

class FollowingRelationShip < ActiveRecord::Base
  belongs_to :follower, class_name: 'User'
  belongs_to :followed_user, class_name: 'User'
end

You capitalized the ‘S’ in relationship. The class is named FollowingRelationShip but your has_many line says that it should be named FollowingRelationship.

Sheesh. Thanks very much. I scoured that for an hour.