0

from my WizardController i've defined N steps.

The first one includes a form (method: put) and a file upload field (image) handled through CarrierWave.

While submitting the form without changing the image, Rails triggers the PUT method while if the image if present / edited it triggers a POST (I suppose for the image upload action) leading to

ActionController::RoutingError (No route matches [POST])

My form has the following structure

<%= form_for @health_facility, url: wizard_path, method: :put, html: {multipart: true} do |f| %>

The same happens while submitting a form_tag (instead of a form_for). It performs a POST even if I've set this

<%= form_tag wizard_path, method: :put, multipart: true, class: 'form-horizontal' do %>

How can I overcome this?

Thank you

matteoredz
  • 13
  • 1
  • 4
  • Many browsers don't support very well PUT request. Here is an interesting [post](http://stackoverflow.com/questions/9551330/put-method-form-for). – Volodymyr Balytskyy Mar 14 '17 at 11:07
  • 1
    @RareFever thank you for your reply. The fact is that I know that Rails add an hidden filed to emulate put method and it correctly appears in the DOM. The problem is that after submitting the form is used POST as method. I know for sure that PUT is working because in previous similar forms it is triggered correctly – matteoredz Mar 14 '17 at 11:14
  • Where did you mount the uploader? On Wizard? If so, could you include the result of `rake routes | grep wizard`. Could you check this post? Do you use the put to update or to upload? Because I think that the path for put is `PUT-> /wizards/:id ->update->update a specific photo` http://stackoverflow.com/questions/12173020/no-route-matches-error-while-uploading-a-file-with-carrierwave – Fabrizio Bertoglio Mar 14 '17 at 12:55

0 Answers0