Forum: Ruby on Rails Join Finder Question (ActiveRecord)

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.
F9a877225fb92fbfa6fa07d8e0c9db6a?d=identicon&s=25 Fernando Ruscitti (oferar)
on 2006-03-29 20:54
Hi

I have a many-to-many relationship between users and roles

class User << ActiveRecord::Base
  has_and_belongs_to_many :roles
end

class Role << ActiveRecord::Base
...
end

There is an user_roles table for the many-to-many and all works as
expected.

Role has an attribute (attr_x).

I want to find the Users that have a Role with attr_x == some val, in
one find.

Is there any simple way to specify in the find that

Person.role[].attr_x == some val?

Thanks very much.
Fernando.
This topic is locked and can not be replied to.