Rails6:不允许的参数:活动存储
Rails 6: Unpermitted Parameter : Active Storage
我有一个名为 Answer
的模型,它可以有很多附件。我已将其指定为 has_many_attached :answer_files
并根据 docs 允许参数但是在这个模型中我不断在日志中得到 Unpermitted parameter: :#<ActiveStorage::Attached::Many:0x0000000012e76aa0>
。我在使用 has_one_attached :logo
的另一个模型中有相同的,并且工作正常。
请注意,我在两个模型中都根据 docs 使用 direct_upload: true
。我不明白的是记录确实保存并且文件被添加到 active_storage_blobs table。它只是没有与我的模型相关联。
我也尝试过重新安装活动存储,但无济于事。
感谢任何帮助。
我在 Reddit 上 u/endenis 的帮助下设法解决了这个问题。答案是关联的一部分,我认为我必须这样做 f.file_field answer.answer_files, multiple: true, direct_upload: true
但这是不正确的。
我不得不这样做f.file_field :answer_files, multiple: true, direct_upload: true
我有一个名为 Answer
的模型,它可以有很多附件。我已将其指定为 has_many_attached :answer_files
并根据 docs 允许参数但是在这个模型中我不断在日志中得到 Unpermitted parameter: :#<ActiveStorage::Attached::Many:0x0000000012e76aa0>
。我在使用 has_one_attached :logo
的另一个模型中有相同的,并且工作正常。
请注意,我在两个模型中都根据 docs 使用 direct_upload: true
。我不明白的是记录确实保存并且文件被添加到 active_storage_blobs table。它只是没有与我的模型相关联。
我也尝试过重新安装活动存储,但无济于事。
感谢任何帮助。
我在 Reddit 上 u/endenis 的帮助下设法解决了这个问题。答案是关联的一部分,我认为我必须这样做 f.file_field answer.answer_files, multiple: true, direct_upload: true
但这是不正确的。
我不得不这样做f.file_field :answer_files, multiple: true, direct_upload: true