문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top