Question about has_many :through association


I have two models called Group and User. A group shall have a leader and
several members, whereas leader and members are of type User.

I am using the following associations:

class Group < ActiveRecord::Base
has_one :group_leader, :class_name => ‘User’
has_many :group_members, :through => :group_leader

class User < ActiveRecord::Base
belongs_to :group
has_many :group_members, :class_name => “User”, :foreign_key =>
belongs_to :group_leader, :class_name => “User”

And also put the following into a migration
add_column :users, :group_id, :integer
add_column :users, :group_leader_id, :integer

Then I assign a group leader to a group and a member to a leader. When I
do a

Group.find(:first).group_members I get the following exception:

ActiveRecord::StatementInvalid: Mysql::Error: Not unique table/alias:
‘users’: SELECT users.* FROM users INNER JOIN users ON
users.group_leader_id = WHERE ((users.group_id = 8))

What is that all about? Any help is highly appreciated. Thank you!