ruby on rails without :remote=> true not working when a file uploader is used in form

remotipart npm (3)

Basically when I include and use a file uploader in my form it seems to cancel out the :remote => true functionality and processes the action as HTML in place of JS. any ideas?

You can't upload files via AJAX, so apparently your request comes as plain HTML, because you don't have anything specific to :js and rails thinks it's just a plain HTML POST request.

gem 'remotipart', '~> 1.2'

and then bundle install

//= require jquery.remotipart


<%= form_for @sample, :html => { :multipart => true }, :remote => true do |f| %>
  <div class="field">
    <%= f.label :file %>
    <%= f.file_field :file %>
  <div class="actions">
    <%= f.submit %>
<% end %>

in Controller

def create
  respond_to do |format|


// Display a Javascript alert
<% if remotipart_submitted? %>
  alert('submitted via remotipart')
<% else %>
  alert('submitted via native jquery-ujs')
<% end %>

AJAX image uploads do not work, at least not in the standard way.

There are newer, HTML5 techniques that make it work, and workarounds using <iframe>

There is a great library that does multiple file ajax upload with progress meter and degrades to use different techniques depending on the browser.

AJAX Upload library:

It will require a little extra work, but the result can be really nice!