开发者

Automatic non-RESTful routes in Rails 3?

开发者 https://www.devze.com 2023-04-08 23:15 出处:网络
We have an app with a large number of non-RESTful, verb-oriented controllers.I remember that long ago, before Rails got the REST religion, you could get automatic routes and helpers for those.Is there

We have an app with a large number of non-RESTful, verb-oriented controllers. I remember that long ago, before Rails got the REST religion, you could get automatic routes and helpers for those. Is there any way to still do this? It's a pain to keep adding 开发者_如何学JAVAGETs every time we add an action, and our app (or perhaps our collective development brain) just doesn't lend itself to RESTfulness.


You can use the "magic route", I believe it's still in the routes file by default, but if you don't have it here it is:

# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'


You can still use a default route like this:

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

to match paths like

  • /monkey/play
  • /monkey/see/1
  • /monkey/hear/1
  • /monkey/eat/1
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号