Rails, how do I chain scopes with an “and” operator between them?
问题 I have a scope that look like this: scope :attr_similar_to, -> (attr, strings) { where("#{attr} similar to ?", "%(#{strings})%") } The way I use this scope is that iterate through a number of attributes and for each attribute I send the attribute into the scope along with a set of multiple strings in the 'strings' variable, which gets sent into this scope as "foo|bar|etc". So for each attribute, I check if the attribute value is similar to any of the strings. The loop where I use this scope