Rails Strong Params - 允许数组的索引

时间:2016-10-10 20:15:43

标签: ruby-on-rails strong-parameters

我正在处理多个文件上传器,我从上传器收到的params类似于:

"pdf_conta"=>{"0"=>#<ActionDispatch::Http::UploadedFile:0x007faed4374738 @tempfile=#<Tempfile:/tmp/RackMultipart20161010-6502-go0te.pdf>, @original_filename="AVENIDA.pdf", @content_type="binary/octet-stream", @headers="Content-Disposition: form-data; name=\"conta[pdf_conta][0]\"; filename=\"AVENIDA.pdf\"\r\nContent-Type: binary/octet-stream\r\n">, 
"1"=>#<ActionDispatch::Http::UploadedFile:0x007faed4374440 @tempfile=#<Tempfile:/tmp/RackMultipart20161010-6502-e5t82z.pdf>, @original_filename="BANDEIRANTES.pdf", @content_type="binary/octet-stream", @headers="Content-Disposition: form-data; name=\"conta[pdf_conta][1]\"; filename=\"BANDEIRANTES.pdf\"\r\nContent-Type: binary/octet-stream\r\n">}}

并且我不能允许该参数,因为如果我将:pdf_conta => {}这样的内容放在我允许的参数上,它会给我Unpermitted parameters: 0, 1的错误。如何允许该哈希具有所需数量的索引?谢谢!

0 个答案:

没有答案