Can't resolve options?

This is weird for me, so I'm just wondering if anyone else comes across this:

I have the following:

def credential_params params.required(:credential).permit(:name,:agent_ids) end 

In my controller, create and update actions. I am using bulk 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! (i.e. allow all), of course, it works.

I feel like I should lose sight of some obvious game here ... does anyone know what it could be?

+4
source share
2 answers

to try

 params.require(:credential).permit(:name, { :agent_ids => [] }) 
+5
source

Got it.

An array is not one of the supported types :

Valid scalar types are String, Symbol, NilClass, Numeric, TrueClass, FalseClass, Date, Time, DateTime, StringIO, IO, ActionDispatch :: Http :: UploadedFile and Rack :: Test :: UploadedFile.

Therefore, the solution should specify an array, for example:

 params.require(:credential).permit(:name, :agent_ids => []) 

Hope others find this helpful.

+5
source

Source: https://habr.com/ru/post/1468876/


All Articles