4

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!

B Seven
  • 44,484
  • 66
  • 240
  • 385
  • Thanks for the answer! My question was 'How do you do the equivalent of Rails.application.routes.recognize_path "/your/path"' in Rails 2.3? It looks like that was the exact inverse of your question. :) – Bryan Larsen Oct 04 '12 at 18:44

2 Answers2

8

You can do this

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

It works in rails 3.1.0.rc4

Lucas Renan
  • 3,787
  • 3
  • 28
  • 35
1

Path of the Request:

request.path

Path of the file:

__FILE__
jdeseno
  • 7,753
  • 1
  • 36
  • 34