Skip to content

Instantly share code, notes, and snippets.

@flash-gordon
Created May 7, 2018 20:02
Show Gist options
  • Save flash-gordon/deef1d0153b2e6c45b0b021cfba2a4d9 to your computer and use it in GitHub Desktop.
Save flash-gordon/deef1d0153b2e6c45b0b021cfba2a4d9 to your computer and use it in GitHub Desktop.
def search_tags(query, tags)
tag_queries = tags.map { |t| pattern(t) }
query.where { tag_queries.reduce(`false`) { |acc, q| acc | array_to_string(self.tags, ',').ilike(q) } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment