How can I display the ending path of a url in rails?
I can display a path like this:
<%= request.request_uri %> or <%= request.path %>
And I will get something like this:
/controller/action/foo1/foo2
How can I just get the ending path without a slash? Like in this ex开发者_如何转开发ample, it would be: "foo2". Is this possible?
request.path.split('/').last
I'm not why you should ever use this though. Using params
is the sensible approach, as @Sam said.
Generally the last part of the url is your :id
.
精彩评论