I am running rails 4.2, with a PG database.
I have an item stored in the database such as (model Item
):
:something => ["1", "2", "3"]
I would like to get the Item.where(:something.include? => "3")
Obviously this is not working - but how are you meant to do this in rails?
According to documentation, something like this should work:
Item.where('something @> ARRAY[?]::varchar[]', ['3'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With