Skip to content

Instantly share code, notes, and snippets.

@thadeu
Created October 16, 2019 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thadeu/dd5f93e969eb3e93ea1e51cefdc6480d to your computer and use it in GitHub Desktop.
Save thadeu/dd5f93e969eb3e93ea1e51cefdc6480d to your computer and use it in GitHub Desktop.
Named Route Rails 5+
# 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