<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rhtml code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 07:16:18 GMT</pubDate>
    <description>DZone Snippets: rhtml code</description>
    <item>
      <title>find out the current url / uri in *.rhtml file</title>
      <link>http://snippets.dzone.com/posts/show/2841</link>
      <description>// find out the current url / uri in *.rhtml file&lt;br /&gt;// is quite simple with the request object&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;% page = request.request_uri %&gt;&lt;br /&gt;page: &lt;%= page %&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;// but then different urls mean the same page &lt;br /&gt;// (../admin = ../admin/ = ../admin/index = ..admin/index/)&lt;br /&gt;// and maybe the id is unwanted too (../admin/show/8)&lt;br /&gt;// so below is an alternative with control on which parameter is used&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %&gt;&lt;br /&gt;page: &lt;%= page %&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Mon, 16 Oct 2006 19:40:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2841</guid>
      <author>ovhaag (Oliver Haag)</author>
    </item>
  </channel>
</rss>
