Rails: find controller for a path no comments

Posted by stephane Sun, 06 Apr 2008 12:20:00 GMT

Huh, seems simple to do :p, but I’ve been seeking for a while to find the answer and dig into rails code to find a simple method to retrieve the controller of a given path (could be useful to build a navigation). There it is:

ActionController::Routing::Routes.recognize_path(path)[:controller]
Comments

Leave a response

Comments