Applications tend to take on a life of their own. Objects grow and take on new state and behavior. This can often lead to unnecessary code bloat and threaten the maintenance profile of your application. Similar behavior occurs with a multi-tenant application. Soon the tenant specific code starts to accumulate and weigh heavy on your app. Postgres provides a JSON data type which is convenient for such customizations.

Unfortunately the docs are a little vague on how to execute a query based one of those JSON field keys.

Here is how it is done for the Order object (orders table) with a JSON attribute/column client_fields:

Order.where("client_fields->> 'sku' = '5970241'")

All of the comparison operators available in Postgres are at your disposal so this feature can be an integral part of your ActiveRecord Scopes.