Rails: Has many through associations — find with AND condition, not OR condition

前端 未结 3 490
盖世英雄少女心
盖世英雄少女心 2021-02-06 19:18

I have the following query method in my ActiveRecord model:

def self.tagged_with( string )
    array = string.split(\',\').map{ |s| s.lstrip }
    select(\'disti         


        
3条回答
  •  庸人自扰
    2021-02-06 20:11

    LOL the solution for this is not a simple task--I thought through it from a SQL standpoint and it was UGLY. I figured somebody else has to have tried this so I did some searching and found this post that should help you:

    HABTM finds with "AND" joins, NOT "OR"

提交回复
热议问题