Find Routing info base on uri
With this code, I can get controller, action information base on a path
Rails.application.routes.recognize_path(path)
To get controller information, just do:
Rails.application.routes.recognize_path(path)[:controller]
And for action:
Rails.application.routes.recognize_path(path)[:action]
Written by Leo.liang
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#