John Smith John Smith - 8 months ago 18
Ruby Question

No route matches [PUT]. How to correctly route?

I have this code for my _form.html.haml:

= form_tag edit_work_flows_path, :method=> 'put' do |f|
-@all_configurations.each do |config|
-if config.configuration_key == 'DUPLICATE_CLAIM_WI_MANAGER'
=hidden_field_tag "config_ids[]",
%label= t('workflow.duplicate_claim_manager')

It is giving the error that "No route matches [PUT]"

However, when I change the form_tag to
it works. But it doesn't go to the page I want. I want it to go to the edit_work_flows_path page. Here is my route:

scope '/settings' do
resource :app_configurations, only: [:edit, :update] do
collection { get 'cover_letter_template' }
resource :work_flows, only: [:edit, :update]

Any idea how to fix this?


No route matches [PUT]

The problem is with your form_tag. When you run rake routes, you will see like the below

   Prefix Verb  URI    Pattern                   Controller#Action
edit_work_flows GET   /work_flows/edit(.:format) work_flows#edit
     work_flows PATCH /work_flows(.:format)      work_flows#update
                PUT   /work_flows(.:format)      work_flows#update

This means the edit_work_flows_path can only accept GET, that is why you got the error. You should change edit_work_flows_path to work_flows_path. The below code should work.

= form_tag work_flows_path, :method=> 'put' do |f|