ruby-on-railspatchputsimple-form-for

Rails simple_form_for update action routing error [POST] with id


I try to update customer object via simple_form_for with Rails 6

From show.html.erb I have <%= render partial: "form", object: @customer, as: 'customer' %>

My form example: _form.html.erb

<%= simple_form_for customer, remote: true, url: customer_path(customer), method: :patch do |f| %>

I don't know why, Rails throw RoutingError

ActionController::RoutingError (No route matches [POST] "/customers/1"):

My routing:

resources :customers, only: %i[show create new update]

Solution

  • config.api_only = false allow Middleware to Rack::MethodOverride

    I have config.api_only = true and that's was my problem.