我正在尝试通过 1 个表单上传带有回形针的多张图片,但我收到了 Unpermitted parameters 错误。
这是我的代码:
模型:
class Recentjacket < ActiveRecord::Base
has_attached_file :jacketimage, :styles => { :medium => "300x300>", :thumb => "100x100>"}, :default_url => "/images/:style/missing.png"
end
控制器:
def recent
@recentjacket = Recentjacket.all
end
def update
params['recentjacket'].keys.each do |id|
@jacket = Recentjacket.find(id)
@jacket.update_attributes(recentjacket_params)
end
redirect_to '/recent'
end
private
def recentjacket_params
params.require(:recentjacket).permit(:jacketimage)
end
html.slim
= form_for recent_path, html: { multipart: true } do |k|
- @recentjacket.each do |j|
= fields_for "recentjacket[]", j do |jacketfields|
= jacketfields.file_field :jacketimage
= k.submit "Update"
因此,数据库中基本上有 12 个最近的夹克,当某些内容发生更改时,它应该覆盖图像。
有谁知道如何解决这一问题?