Good day.
I am a beginner in the "rails", so I will ask stupid questions))
I have a problem with Rails 5.1 , it would seem, in the most unexpected place ...
We have a TestsController controller and a Test model in the database. I am trying to create standard routes for them ( routes.rb ):
resources :tests Routes are created:
tests GET /tests(.:format) tests#index POST /tests(.:format) tests#create new_test GET /tests/new(.:format) tests#new edit_test GET /tests/:id/edit(.:format) tests#edit test PATCH /tests/:id(.:format) tests#update PUT /tests/:id(.:format) tests#update DELETE /tests/:id(.:format) tests#destroy Index and new / create work as they should, but with the edit / update question.
Editing form:
<%= form_with model: @test do |form| %> ... It seems to even form the correct html , in accordance with the documentation:
<form action="/tests/288" accept-charset="UTF-8" data-remote="true" method="post"> <input type="hidden" name="_method" value="patch" /> ... But when sending a request, I always get the error:
No route matches [POST] "/tests/288" Those. the request, in theory, should be processed in Rails as PATCH , but this does not happen, it is always perceived as POST .
Tell me, please, what should I check to get PATCH ?
UPD
According to the post , it is proposed to connect to the project rails-ujs , which I did. However, this did not fix the error, it still exists, but now in javascript:
POST http://localhost:3000/tests/289 404 (Not Found) Rails.ajax @ application-a4b54ac3a3b7244f9d4baffe76072e24d3eaea04129b5eac919dc5ad4ab1233d.js:844 Rails.handleRemote @ application-a4b54ac3a3b7244f9d4baffe76072e24d3eaea04129b5eac919dc5ad4ab1233d.js:1201 (anonymous) @ application-a4b54ac3a3b7244f9d4baffe76072e24d3eaea04129b5eac919dc5ad4ab1233d.js:801