I want to know if an arbitrary path can be mapped to a route
recognized_request_for accomplishes what I want, but I can't get it to work in my controller.
Specifically, how can I execute recognized_request_for or something that accomplishes the same task from my controller?
path is relative while url is absolute.
rake routes will list all of your defined routes, which is useful for tracking down routing problems in your app, or giving you a good overview of the URLs in an app you're trying to get familiar with.
Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.
For Rails 3 the call is
Rails.application.routes.recognize_path
Instead of
ActionController::Routing::Routes.recognize_path
Example:
def path_exists?(path)
Rails.application.routes.recognize_path(path)
true
rescue ActionController::RoutingError
false
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With