Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot submit my file form #158

Open
Sashkan opened this issue Aug 23, 2016 · 1 comment
Open

Cannot submit my file form #158

Sashkan opened this issue Aug 23, 2016 · 1 comment

Comments

@Sashkan
Copy link

Sashkan commented Aug 23, 2016

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

@AhmadSaleem
Copy link

AhmadSaleem commented Aug 28, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants