Forum: Ruby on Rails has_and_belongs_to_many

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sijo k. (Guest)
on 2009-02-27 09:55
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
This topic is locked and can not be replied to.