0

I tried something like this...

result = User.includes(:detail).where("detail.strings->'the_key') IS NOT NULL")

But that doesn't seem to work. I want to join User to Detail and then check the column strings in the table Detail to see if the json stored in strings has the_key. That doesn't work. I also tried use strings-> but that didn't work as well

  • 1
    https://stackoverflow.com/questions/19422640/how-to-query-for-null-values-in-json-field-type-postgresql – max May 14 '19 at 13:41

1 Answers1

0

Try this

User.joins(:detail).where("detail.strings ->> 'the_key' IS NOT NULL")
Roman Alekseiev
  • 1,854
  • 16
  • 24