Join three tables with a common join table

I have the following three tables: user, role and project.

Should I simply do it some other way?

I did something similar using an Observer to create the join object. The reason for this was that I needed to create a join when either one side was created or the other side was. So in one Observer, I could watch both models, and respond to either one.

Walter

Thanks.
  I just got it working by doing this:

has_and_belongs_to_many :users,
:join_table => "projects_roles_users",
:foreign_key => 'role_id',
:association_foreign_key => 'project_id',
:insert_sql => 'INSERT INTO
            projects_roles_users(project_id,role_id,user_id)
            VALUES(#{id}, #{role_ids}, #{user_ids})'

Thanks.
  I just got it working by doing this:

has_and_belongs_to_many :users,
:join_table => "projects_roles_users",
:foreign_key => 'role_id',
:association_foreign_key => 'project_id',
:insert_sql => 'INSERT INTO
            projects_roles_users(project_id,role_id,user_id)
            VALUES(#{id}, #{role_ids}, #{user_ids})'