How do you use ActionDispatch::Routing::RouteSet recognize_path?

拜拜、爱过 提交于 2019-12-22 08:01:34

问题


How do you use ActionDispatch::Routing::RouteSet recognize_path?

I want to get the current path for the view.

I tried <div id="<%= ActionDispatch::Routing::RouteSet::recognize_path %>"> but got "undefined method `recognize_path' for ActionDispatch::Routing::RouteSet:Class".

Thanks!


回答1:


Path of the Request:

request.path

Path of the file:

__FILE__



回答2:


You can do this

Rails.application.routes.recognize_path "/your/path"

It works in rails 3.1.0.rc4



来源:https://stackoverflow.com/questions/6459403/how-do-you-use-actiondispatchroutingrouteset-recognize-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!