当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - How do you use ActionDispatch::Routing::RouteSet recognize_path?

问题描述:

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!

网友答案:

Path of the Request:

request.path

Path of the file:

__FILE__
网友答案:

You can do this

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

It works in rails 3.1.0.rc4

分享给朋友:
您可能感兴趣的文章:
随机阅读: