Reputation: 1088
How can I get information about controller and action names for any (not only current) url, if there is a route rule for this?
For example:
function_i_need('/pages/5')
returns
{:controller => 'page', :action => 'show', :id => 5}
UPD: Answer found Rails parse url to hash(Routes)
Upvotes: 10
Views: 6386
Reputation: 567
you can do this:
Rails.application.routes.recognize_path "/pages/5"
Upvotes: 18