ActiveRecord - has_many :through w auto referenced table

Happy New Year to all rubyist and railist … only 3 days in new yaer
and already a question …

I am using a ‘User’ table which is self-referenced via a joint
Credential table…
according to the follwoing declarations :

class User < ActiveRecord::Base
has_many :credentials, :dependent => true
has_many :referees, :through => :credentials
has_many :referenced_users, :through => :credentials

class Credential < ActiveRecord::Base
belongs_to :referee, :class_name => ‘User’, :foreign_key =>
‘referee_id’
belongs_to :referenced_user, :class_name => ‘User’ , :foreign_key =>
‘referenced_user_id’

In my controller, when I try to get all referees from a user :

@contacts = current_user. referees # current_user.id = 22

I get an error :

Mysql::Error: Unknown column ‘credentials.user_id’ in ‘where clause’:
SELECT users.* FROM users INNER JOIN credentials ON users.id =
credentials.referee_id
WHERE (credentials.user_id = 22)

what’s missing in the User declarations ?

thanks for your lights !

kad