タグレコードを関連付けている従業員のみを選択するにはどうすればよいですか?つまり、1つ以上のタグレコードが関連付けられている従業員レコードのみを選択します。
class Employee < ActiveRecord::Base
has_and_belongs_to_many :tags
end
class Tag < ActiveRecord::Base
has_and_belongs_to_many :employees
end
以下のクエリ(これは間違っています)は、私が何をしようとしているのかを皆さんに教えてくれます。
Employee.includes(:tags).where("tags.id != nil")