update jsonb with update_column vs update_all

Viewed 210

I'm using rails 7 with postgresql

I'm trying to update an jsonb attribute on my model

with

model.update_columns("published_data = jsonb_set(published_data, '{structure}',  '[\"file\"]')")

it rises an error

undefined method `transform_keys'

but with

Model.where(id: model.id).update_all("published_data = jsonb_set(published_data, '{structure}',  '[\"file\"]')")

it works perfecly fine

I don't understand why

0 Answers
Related