Rectangle 27 0

May be the cause is incompatibility of current remotipart version with jquery 1.9 used in latest jquery-rails gem. It can be solved by manually applying this patch (works for me).

jquery - rails - remotipart not working in Rails 3.2.8 - Stack Overflo...

ruby-on-rails jquery
Rectangle 27 0

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 three 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.

Overriding jquery.iframe-transport was the source of my problems too. Thanks for figuring this out Matt.

javascript - jQuery Remotipart sending [object Object] to server - Sta...

javascript jquery ruby-on-rails file-upload ruby-on-rails-3.2
Rectangle 27 0

$("#my_div").html("<%= escape_javascript(render :partial => 'my_partial') %>");

Same error, why would that produce a different result?

jquery - Rails escape_javascript and remotipart - Stack Overflow

jquery ruby-on-rails ruby remotipart
Rectangle 27 0

I figured it out. It is resolved when adding the (required) i-frame transport library. That one's on me.

//= require jquery.iframe-transport

this didn't fix the issue for me :/

jquery - Rails ajax fileupload (remotipart) - Stack Overflow

jquery ruby-on-rails ajax file-upload
Rectangle 27 0

At first glance - you have not set :remote => true, which is necessary for the form to work with ajax, so it should be:

<%= form_for @file_upload, :remote => true, :id => "form_feedback_attachment", :url => { :controller => "widgets", :action => "feedback_attachment_upload" }, :html => {:multipart => true} do |f| %>

At the controller, if you are using this action for something else this may be a problem, so you should wrap it like this:

if @file_upload
   @file_upload.feedback_attachment = params[:file_upload][:feedback_attachment]
     respond_to do |format|

Also note that i have removed the first line. Hope this helps. {:

forms - Rails Jquery upload file using remotipart gem NoMethodError: u...

ruby-on-rails-3 forms file-upload jquery-file-upload remotipart
Rectangle 27 0

Figured out a solution. I was a little confused on how the JS for Remotipart works. After a little research, here's what I found:

Remotipart works simply by binding to the ajax:aborted:file event, which is triggered when jQuery UJS (which handles traditional AJAX form submits) detects a file within the form. Since that script (along with the dependent iFrame transport plugin) is already included on the page, all you need to do is manually add


Another issue, though, is that if this form is submitted, it will still likely fail to upload the file due to the lack of the CSRF token. The solution is to manually add a hidden input tag with the token.

Here's the final markup that worked for me (I'm using .eco templates with a little jQuery to grab the value of the CSRF meta tags on the page):

<form accept-charset="UTF-8" id="image-upload-form" action="/projects/<%= @project.get('id') %>" method="post" enctype="multipart/form-data" data-remote="true">
    <input name="project[cover_photo]" type="file" />
    <input type="hidden" name="<%= $('meta[name="csrf-param"]').attr('content') %>" value="<%= $('meta[name="csrf-token"]').attr('content') %>" />
    <input name="_method" type="hidden" value="put" />
    <button id="add-photo">Save</button>

Hope this will help spare someone else the same trouble I had!

jquery - AJAX image upload with Rails, Backbone, Remotipart - Stack Ov...

jquery ruby-on-rails ajax backbone.js remotipart
Rectangle 27 0

I finally got to fix the same issue trying something like:

$("#my_div").html("<%= escape_javascript(render :partial => 'my_partial').gsub('&quot;', "'") %>");

jquery - Rails escape_javascript and remotipart - Stack Overflow

jquery ruby-on-rails ruby remotipart