【发布时间】:2023-03-23 17:39:01
【问题描述】:
在我的应用程序中,我正在创建一个上传多个文档的表单。现在我已经发布了带有 2 个上传文档的表单,但由于错误而无法保存在数据库中。但是我得到了上面提到的所有参数。请帮我解决这个问题。
在控制器中:
def create
@sr_document = SrDocument.new(sr_document_params)
end
def sr_document_params
params.require(:sr_document).permit(:file_type, :file, :service_request_id, :file_file_name, :file_content_type, :file_file_size)
end
在日志中:
"sr_document"=>{"file"=>[
@tempfile=#, @original_filename="Reliance Web-Chat.pdf", @content_type="application/pdf", @headers="Content-Disposition: 表格数据;名称=\"sr_document[文件][]\";文件名=\“信赖 Web-Chat.pdf\"\r\nContent-Type: application/pdf\r\n">,
@tempfile=#\, @original_filename="Flipkart.pdf", @content_type="application/pdf", @headers="内容配置:表单数据; 名称=\"sr_document[文件][]\"; filename=\"Flipkart.pdf\"\r\nContent-Type: application/pdf\r\n">
]}
【问题讨论】:
-
不允许的参数:文件
-
file是sr_documents表中的字段吗?你能告诉我们form吗?
标签: ruby-on-rails ruby-on-rails-4