I'm working on Ruby on rails 2.3.8, and I'd like to build a functionality to follow users.
For this purpose, I've created 2 tables: users and followings, with their respective models:
class User < ActiveRecord::Base
has_and_belongs_to_many :followings, :foreign_key => "follower_id"
end
class Following < ActiveRecord::Base
has_and_belongs_to_many :users, :foreign_key => "follower_id", :class_name => "User"
end
Now, when I try to execute current_user.followings.all
(with a valid current_user, of course), it throws me the following exception:
'followings_users' doesn't exist: SELECT 'followings'.* FROM `followings` INNER JOIN 'followings_users' ON 'followings'.id = 'followings_users'.following_id WHERE ('followings_users'.follower_id = 1 )
I can't make this work. I don't know why it asks me for a "followings_users" table. What if I want to call it just "followings"?
What am I doing wrong here?