3

I need to pass the path for current view to a render for partial within that view in order to generate a link (in the partial) to the view itself. How can I get the path for the current view when javascript is disabled?

<%= render "errors", object: @car.plate, path: (what?)%>
Ali J
  • 33
  • 2
  • 5

1 Answers1

7

Depending on what you actually need, one of these might help: request.url, request.path

if you to know the controller/action being called: controller_name, action_name

Matt
  • 13,948
  • 6
  • 44
  • 68
  • `request.path` is what I want. Thank you. – Ali J Feb 04 '19 at 15:04
  • 1
    `controller_path` is the correct answer! on nested routes, request.path would return things like customer/1/articles but controller_path returns `articles` and thats where the view is. – chmich Apr 06 '23 at 15:04