如何查看某个Action的RESTful 类型?(how to determine the restful type of an action in Rails? )
访问量: 3749
今天为了这个问题想了半小时。呃。。。又是看RAILS源代码又是查文档啥的。 后来才发现,有个灰常简单的方法: ( today I spent half an hour on this question, checking both the source code and the documentation. at last, I found this very simple solution: )
# in rails application controller. params is the common parameter as you know. def restful_method(params) params[:authenticity_token].blank? ? 'get' : ((params[:_method]) || 'post') end
a bit more about the source code, see: gems/railties-3.0.8/lib/rails/tasks/routes.rake