Routing issues with multi-part forms on Heroku
This is a very bizarre problem, and unfortunately I can't provide a ton of information since I don't even know where to begin diagnosing the problem. I'm hoping somebody hear magically knows what to do, and I'm happy to clarify as necessary.
For some reason, anytime I submit a new multi-part form with a file attachment on Heroku using Chrome, I am sent upon submitting to the default "index" action--that is, the page I would be sent to if I had submitted a GET instead of a POST.
I'm using standard RESTful routes in Rails, so I have the following in my routes.rb:
resources :documents do
member do
get :download, :follow
end
end
My forms are pretty standard:
<%= form_for @document, :html => { :multipart => true } do |f| %>
<!-- Form code -->
<% end %>
But again, this is being treated as a GET rather than a POST request, so I am simply redirected to /documents. This is true even if I manually specify :method => :post
in the form definition.
The really, really bizarre thing 开发者_StackOverflowis that this is only happening on Heroku and only happening with Chrome. The forms work fine on my local dev version using Chrome or on Heroku using Safari.
There is no redirect occurring anywhere in the code, and when I check the Heroku logs it's only reporting a GET to /documents, never a POST with subsequent processing that could explain this.
Any help would be greatly appreciated. I really don't know where to begin trying to solve this.
UPDATE: I am using Chrome for Mac, version 12.0.742.53 beta.
Here is the form output.
<form accept-charset="UTF-8" action="/documents" class="new_document" enctype="multipart/form-data" id="new_document" method="post">
<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="q8Qv4q9BXdV4yWzsPx9cgZoFGhJHxj6Nzje/SSnYsYo=" /></div>
....
<input type="file" name="document[file]" />
....
</form>
Nothing seems amiss with the routes, which include the following:
POST /documents(.:format) {:action=>"create", :controller=>"documents"}
Could you confirm that you have <%= csrf_meta_tag %>
in your view
精彩评论