Is there a way to display the routes in a Rails view (pretty much like Rails routes does in Rails 5)?
Rails.application.routes.routes.map { |r| r.path.spec.to_s }
#=> "/users/:id(.:format)"
If you want to get routes in the form they appear in console when you run rails routes:
Rails.application.routes.routes.map(&:name).compact.map { |route| "#{route}_path" }
#=> user_path
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