I am trying to combine Carrierwave and jQuery file uploads. The files are being uploaded, but I am facing an issue with fetching the parameters.
This is how the parameters are passed:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Q6AvptpHm59DMIJy86g9hGCzjhUnP8cwpIHZIntAplvYrj+J5UhifXiLp/bxKitHO9WfjYRPLEhaqIKia3xZkw==", "myfile"=>{"attachment"=>[#<ActionDispatch::Http::UploadedFile:0x007fd46b3def68 @tempfile=#<Tempfile:/tmp/RackMultipart20150117-31080-b37zni.png>, @original_filename="Screen Shot 2015-01-17 at 12.18.19 PM.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"myfile[attachment][]\"; filename=\"Screen Shot 2015-01-17 at 12.18.19 PM.png\"\r\nContent-Type: image/png\r\n">]}, "myfolder_id"=>"1"}
I am trying to fetch these parameters in the controller this way:
@myfile = @parentfolder.myfiles.new(attachment: params[:myfile_attributes])
Which is clearly wrong. Any help would be appreciated!! :)
Look in your log:
Parameters: { ... "myfile"=>{"attachment"=>[....]} ... }
and try this:
params[:myfile][:attachment]
or this (if i right, i see that your attachment in the array):
params[:myfile][:attachment].first