I am uploading images which POSTs the following params:
Parameters: {"url"=>"https://bucket.s3.amazonaws.com/image014.jpg",
"filepath"=>"/uploads%2F1381509934146-1t5a44loikwhr529-1d68490743e05a1287fea45ed4ed9e59%2Fslide0005_image014.jpg",
"filename"=>"slide0005_image014.jpg",
"filesize"=>"30807",
"filetype"=>"image/jpeg",
"unique_id"=>"1t5a44loikwhr529",
"choice"=>["https://bucket.s3.amazonaws.com/image014.jpg"]}
And here is my form:
<%= s3_uploader_form callback_url: choices_url, callback_param: "choice[]", id: "s3-uploader" do %>
<%= file_field_tag :file, multiple: true %>
<button type="submit" class="btn btn-primary start">
<% end %>
And in my controller I have:
#app/controllers/choices_controller
def create
@choice = Choice.create!(choice_params)
if @choice.persisted?
respond_to do |format|
format.html { redirect_to choices_path }
format.json { head :no_content }
end
end
end
def choice_params
params.require(:choice).permit(:url, :filepath, :filename, :filesize, :filetype)
end
But, it returns the error:
NoMethodError (undefined method `permit' for #<Array:0x007f903e380060>):
app/controllers/choices_controller.rb:49:in `choice_params'
app/controllers/choices_controller.rb:24:in `create'
Can you tell me what I am doing wrong here? All I would like to do is:
1) Add the "url" param to the DB 2) Titlelize the "filename" param and then submit that to the DB.
Thanks very much!