Remotipart sending [object Object] to server. #48

dtuite opened this Issue Nov 6, 2012 · 3 comments


None yet

3 participants


I have a form for uploading a file.

<%= form_for @import, remote: true do |f| %>
    <%= f.label :file, "Attach a CSV file" %>
    <%= f.file_field :file %>
  <%= f.submit :upload %>

<% end -%>

Unfortunately, when I submit the form with a file attached, it doesn't seem to arrive at my controller action correctly. The params hash has stringified JS objects as keys.

Started POST "/file_imports" for at 2012-11-06 01:00:49 +0000
Processing by FileImportsController#create as JS
  Parameters: {"object Object"=>{","=>{"object Object"=>{","=>{"object Object"=>nil}}}}}`

Looking into the Remotipart source, I can't seem to understand what it is supposed to do. For example, in vendor/assets/javascripts/jquery.remotipart.js, Line 22 has the following: = form.serializeArray();

A little further down, the settings are sent to the server via $.rails.ajax(settings).

The $.fn.serializeArray() method returns an array of JS objects. If we assign them to the data attribute of a call to jQuery.ajax(), that would account for the serialized object parameters I'm seeing on the server. We need to pass an object as the data attribute, not an array of objects?

Am I doing something wrong or how exactly is this meant to work?


I'm having the same problem. Would love some guidance on the fix.


After a ton of debugging and reading through lots of code, I finally have the latest gem working with Rails 3.2.8. I was nailed by two gotchas: (1) I was disabling my file input field prior to form submission and this causes remotipart to ignore it for inclusion in the iframe submission. You must make sure your file inputs are enabled. This is the direct cause of the bug you are seeing. (2) In the course of my debugging, I was overriding jquery.iframe-transport with the latest upstream source and it doesn't have support for the X-Http-Accepts hidden variable in the iframe. You must use the version bundled with the remotipart gem. (3) Don't forget to wire up a callback for ajax:complete on the form if you are using a datatype other than 'script'. This is the default if you don't specify dataType in the global ajax options, or use the data-type attribute on the form.


@mattolson Thanks for all the info. So I guess I can clos this now, as it sounds like it's not specifically a remotipart issue.

@JangoSteve JangoSteve closed this Feb 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment