Are default routes designed with Rails 3?

I have a gem of Rails 3 that is designed for basic user authentication and authorization. Inside this gem config/routes.rbis defined as follows

resources :users
match '/:controller(/:action(/:id))'

When I make rake routesfrom an application that requires this stone, I get the following routes

rake routes|grep users
users GET   /users(.:format)               {:controller=>"users", :action=>"index"}
users POST  /users(.:format)               {:controller=>"users", :action=>"create"}
new_user GET  /users/new(.:format)         {:controller=>"users", :action=>"new"}
edit_user GET  /users/:id/edit(.:format)   {:controller=>"users", :action=>"edit"}
user GET   /users/:id(.:format)            {:controller=>"users", :action=>"show"}
user PUT   /users/:id(.:format)            {:controller=>"users", :action=>"update"}
user DELETE /users/:id(.:format)           {:controller=>"users", :action=>"destroy"}

This is what I expect.

However, when I try to access the following routes through the browser

/users/137
/users/137/edit

I get the following error in the logs

AbstractController::ActionNotFound (The action '137' could not be found for UsersController):
  actionpack (3.0.0) lib/abstract_controller/base.rb:114:in `process'
  actionpack (3.0.0) lib/abstract_controller/rendering.rb:40:in `process'
  ...

Interestingly, the following paths work

/users/show/137
/users/edit/137

Also, if I add the following to the route.rb file in an application that requires a stone, everything works as expected.

resources :users

Is there something I am missing or is this a mistake?

, , , env

RAILS_RELATIVE_URL_ROOT="/my_app"

config.ru

map '/my_app' do
  run MSEL::Application
end
+3
2

, . , , . rake routes grepping . , , . match '/:controller(/:action(/:id))', . , /users/show/ 137 , RESTful. , . rake routes .

+2

Rails 3.1

root :to => 'ControllerName#Action'

.

0

Source: https://habr.com/ru/post/1766237/


All Articles