User私は 2 つのモデルを持っていServiceます。Userhas_and_belongs_to_many についてServicesも同じことが言えますServices:
class User < ActiveRecord::Base
has_and_belongs_to_many :services
end
class Service < ActiveRecord::Base
has_and_belongs_to_many :users
end
選択したサービスを提供するすべてのユーザーを見つける必要があります。何かのようなもの:
@users = User.where(:services_ids => [2,3,4])