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

1 Answer 1

0

Try this

User.joins(:detail).where("detail.strings ->> 'the_key' IS NOT NULL")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.