This is bizarre to me, so I'm just curious if anyone else has run into this:
I've got the following:
def credential_params
params.required(:credential).permit(:name,:agent_ids)
end
In my controller create and update actions I'm using mass assignment with the above parameter call...
@credential.update_attributes(credential_params)
But I still get Unpermitted parameters: agent_ids
If I change this to params.required(:credential).permit!
(ie permit all) of course it works.
I feel like I must be overlooking some obvious gotcha here... anyone know what it might be?
try
params.require(:credential).permit(:name, { :agent_ids => [] })
Got it.
An array isn't one of the supported types:
The permitted scalar types are String, Symbol, NilClass, Numeric, TrueClass, FalseClass, Date, Time, DateTime, StringIO, IO, ActionDispatch::Http::UploadedFile and Rack::Test::UploadedFile.
Therefore the solution is to specify an array, like so:
params.require(:credential).permit(:name, :agent_ids => [])
Hope others find this useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With