Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

find out the current url / uri in *.rhtml file (See related posts)

// find out the current url / uri in *.rhtml file
// is quite simple with the request object

<% page = request.request_uri %>
page: <%= page %>

// but then different urls mean the same page
// (../admin = ../admin/ = ../admin/index = ..admin/index/)
// and maybe the id is unwanted too (../admin/show/8)
// so below is an alternative with control on which parameter is used

<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %>
page: <%= page %>


You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts