开发者

How can I display the ending path of a url in rails?

开发者 https://www.devze.com 2023-01-30 07:49 出处:网络
I can display a path like this: <%= request.request_uri %> or <%= request.path %> And I will get something like this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消