As you know, the line in routes.rb - resources :articles - will give out routes like:

 GET / articles / articles # index articles_path
 GET / articles / new / articles # new new_article_path
 POST / articles / articles # create articles_path
 GET / articles /: id / articles # show article_path (: id)
 GET / articles /: id / edit / articles # edit edit_article_path (: id)
 PATCH / PUT / articles /: id / articles # update article_path (: id)
 DELETE / articles /: id / articles # destroy article_path (: id)
  1. Is it possible in the rails to replace the PATCH method ONLY with the put or post method? Maybe somehow disable globally or switch work with this method?
  2. If it is possible to change the stupid route, then how can I change the string resources :articles ?
  • The PATCH method is not just there. What is your reason for suddenly turning it off? - Vitaly Emelyantsev
  • @VitaliyEmeliantsev "Network configuration policy" within the company. The patch method does not reach the server. I am aware of what REST is, why PATCH is there and where is rails here - if you don’t have to change / switch a patch in rails or you don’t know, say so! - Stanislav Ilyin
  • The interesting thing about this is that the update from ActiveRecord follows the more semantics of PATCH , but if you use it with all (known) fields, you will get almost PUT . Pretty funny situation. - D-side
  • @ D-side PUT changes all fields. PATCH is only one. But as methods of HTTP, they are different ... - Stanislav Ilyin

2 answers 2

Yes, easily.

 resources :articles, except: :update do put :update, on: :member end 

With the exception of order, this is the same thing that is happening now in Rails, just in a slightly different form: member is the argument of a single route, not a modifier block ( member do ... end ) for a group of routes.

Everything else works as usual.
No oddities like another parameter name or the like.

    You can, for example, like this:

     resources :articles, except: :update do match via: :put, action: :update end 

    Then you will have a PUT to articles#update . But : the parameter under ID articles will not be called params[:id] , but params[:article_id] . It will be necessary to take into account in the controller.

    Or you can write like this:

     resources :pages, except: :update do match ':id', via: :put, action: :update, on: :collection end 

    Then you will have a PUT to articles#update with the params[:id] parameter. Changes will only affect routes in routes.rb .