Querying your jsonb column It’s time to use some query operators. PostgreSQL has many others, so read the documentation for a complete list.
Also, always remember to EXPLAIN the queries you’re executing; that way you can adapt your indexes for a better performance.
Users that opt-in newsletter
# preferences->newsletter = true
User.where('preferences @> ?', {newsletter: true}.to_json)