Rails: join with multiple conditions

前端 未结 3 609
遥遥无期
遥遥无期 2020-12-30 12:54

I have a simple model like

class Interest < ActiveRecord::Base
  has_and_belongs_to_many :user_profiles
end

class UserProfile < ActiveRecord::Base
  h         


        
3条回答
  •  半阙折子戏
    2020-12-30 13:35

    Try IN (?) and an array:

    UserProfile.joins(:interests).where('interests.id IN (?)', [1,2,3,4,5])
    

提交回复
热议问题