JangoSteve/remotipart

Cannot submit my file form

Opened this issue · 1 comments

Hello, I'm stuck between a rock and a hard place with this gem.

I used the exact same code as in the tutorial, but I can't get it to work.

At first, I tried this:

      <%= form_for(@resource, remote: true, multipart: true) do |f| %>
    <%= f.file_field :file %>
    <%= f.submit %>
<% end %>

Here's the matching controller:

  def create
    respond_to do |format|
        format.js
    end
  end

And the matching js file:

alert('success!');

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

When I submit the form, nothing happens, and I get the following error in my logs:

Completed 406 Not Acceptable in 11ms

ActionController::UnknownFormat - ActionController::UnknownFormat:

Now the finny part is, if I specify the format, by using format: :js, the error disappears, but the form doesn't send anything. In fact, here are the request params:

{"controller"=>"briefs", "action"=>"new_feed", "format"=>"js"}

And the js file sends the 'submitted via native jquery-ujs' message.

Did I miss something ? I double checked all js inclusions, I got them all :

//= require jquery
//= require jquery_ujs
//= require jquery.remotipart

Thanks a lot

Facing the same issue. My rails version is 4.2.1, ruby version 2.2.1 and jquery-rails version 4.0.5.