Pluck jsonb fields in Rails
If you have a jsonb field and you want to make a query to only return some nested value, you can use pluck
:
UserActivity.pluck("raw_data->'activity'->'type'")
=> ["rowing", "running"]
Tweet
If you have a jsonb field and you want to make a query to only return some nested value, you can use pluck
:
UserActivity.pluck("raw_data->'activity'->'type'")
=> ["rowing", "running"]
Tweet