Created
October 16, 2019 14:48
-
-
Save thadeu/dd5f93e969eb3e93ea1e51cefdc6480d to your computer and use it in GitHub Desktop.
Named Route Rails 5+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Return a named route to current url requested | |
def route_name | |
Rails.application.routes.router.recognize(request) do |route, _| | |
return route.name.to_sym | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment