I am using a JSONB column where the data is stored as { key => [value, value, value ] } How do I write a scope that returns records which contain a particular value in the array of a particular key?
I've figured out how to search simple JSON Hashes;
scope :rice_flour, -> { where("ingredients ->> 'flour' = ?", "rice") }
...but this query type still escapes me. Everything I have looked up lays things out in raw SQL commands, and I am looking for how to write tidy Rails Scopes.