Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
Created July 19, 2017 05:34
Show Gist options
  • Save HungYuHei/c58ba2f9ca47dd84bc1e43d83298ea3e to your computer and use it in GitHub Desktop.
Save HungYuHei/c58ba2f9ca47dd84bc1e43d83298ea3e to your computer and use it in GitHub Desktop.
Rails PostgreSQL jsonb query array
scope :by_tags, -> (tags) { where("meta->'tags' ?& ARRAY[:tags]::text[]", tags: tags) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment