开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜