2

I have a languages column which is an array of strings with

add_column :table, :languages, :string, array: true, default: []

When I use update_attributes on that model, all columns are being updated except the languages column which remains []

Is there anything special needed to do here?

1 Answer 1

1

When you post an array onto an action in the controller, you should permit like this:

params.require(:table).permit( {:languages => []}, :other_field, :other_field2... )
Sign up to request clarification or add additional context in comments.

5 Comments

languages is permitted in the table_params
Is it permitted as an array?
this kind of permission will only allow empty arrays
I copied/pasted this from an app of mine and it is working perfectly... It tells the controller to permit languages as an array, not an empty array
Glad to having helped.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.