Displaying rails routes from console
Displaying rails routes from rails console / like sextant. Show HTTP Verbs, name, path and action, in development env, you can use Rails::Application::RouteInspector
inspector = Rails::Application::RouteInspector.new
inspector.collect_routes(Rails.application.routes.routes)
And in production :
Rails.application.routes.routes.map do |j|
{
path: "#{j.path.spec}.format",
verb: j.verb.inspect.gsub(/\W/, ""),
controller: j.defaults[:controller],
action: j.defaults[:action]
}
end
Written by Agung Prasetyo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#