Rails wrap_parameter does not work as expected

I work with AngularJS and the jQuery-file-uploader plugin. I configured rails to transfer my parameters with

ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end 

This works great for everyone except when I try to upload my files. I use the uploader plugin a little differently than usual, but it should work anyway. Rather, letting the plugin upload files when they are added, I create a new entry and THEN upload the files. The request starts correctly, but the parameter for the file (s) / is not wrapped with rails. In my magazines I get

 Processing by MeetingsController#update as JSON Parameters: {"icon"=>#<ActionDispatch::Http::UploadedFile:0x007fde79178b58 @original_filename="006.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"icon\"; filename=\"006.png\"\r\nContent-Type: image/png\r\n", @tempfile=#<File:/var/folders/_v/qsm9g7nn00s0jmfkynmvwp140000gn/T/RackMultipart20130505-15753-17ig2it>>, "id"=>"35"} 

I expect to see the parameter

 { :meeting => { :icon => ... }} 

In my MeetingsController I have

 wrap_parameters :meeting, include: [..., :icon, ...] 

Creating a record that also passes through this controller works fine, and the parameters are wrapped as expected, however this will not work. Am I doing something wrong?

+3
ruby-on-rails jquery-file-upload
May 05 '13 at 2:44
source share
1 answer

This is because the file upload request has the format multipart / form-data.

To activate autowrappring in this format, you can add a format option:

 class MeetingsController < ApplicationController wrap_parameters :meeting, include: [..., :icon, ...], format: [:json, :multipart_form] ... end 
+1
Jan 16 '14 at 11:35
source share



All Articles