Has_and_belongs_to_many


#1

Hi
I have the models

1)CompanyRequest
has_many :contacts
2)Contact
belongs_to :company_request
has_and)_belongs_to_many :roles
3)Role
has_and)_belongs_to_many :contacts

and the join table contact_roles containg role_id,contact_id

I have to find out the primary contact(ie contact with role_id = 1

)corresponding to a request

    Could you please help me to solve this?

Thanks in advance
Sijo