Finding a Rails Route from a Path

Fred Polgardy and I were looking up how to find out what path in the browser corresponds to what controller/action combination in a Rails application today and I realized that I've looked this up before... So I'm putting this information here so I can find it in the future:

(from inside the console)
>> ActionController::Routing::Routes.recognize_path '/seo/hotness/path/705105'
=> {:controller=>"products", :action=>"show", :id=>"705105"}

Yeah I know you can do a 'rake routes' and hunt around but this gets me where I need to be quicker.

Comments

jason said…
OK how about if you wanted to find out what the nested resources were?

/categories/1/products/3

So instead of returning just "product", it might return "[category, product]"

Is that similar?

Popular posts from this blog

What's a Good Flog Score?

Point Inside a Polygon in Ruby

SICP Wasn’t Written for You