I'm trying to upload multiple images with paperclip through 1 form, but I'm getting a Unpermitted parameters error.
This is my code:
Model:
class Recentjacket < ActiveRecord::Base
has_attached_file :jacketimage, :styles => { :medium => "300x300>", :thumb => "100x100>"}, :default_url => "/images/:style/missing.png"
end
Controller:
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"
So basically there are 12 recentjackets in the database and when something is changed, it should overwrite the image.
Does anyone know how to fix this?