Unable to find records with corresponding JSONB column

Viewed 36

Given a model:

class Search < ApplicationRecord
  store_accessor :query, :city, :tags
end

search_1 = Search.create(query: { city: 'Denver', tags: ['patio', 'food-truck'] })

One would think that this query would work right?

Search.where("array[query->>'tags'] @> array[:keys]::text[]", keys: search_1.tags)

Anyone able to offer advice on why this isn't working?

0 Answers
Related