<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Yup Dot Com: Rails History Plugin</title>
    <link>http://www.yup.com/articles/2006/06/01/rails-history-plugin</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Advanced Web Services</description>
    <item>
      <title>Rails History Plugin</title>
      <description>&lt;p&gt;&lt;img style="float: right; border: 1px dotted #ccc; margin: 4px; padding: 4px" src="http://static.flickr.com/29/63434548_c6e9ba9b6c_m.jpg" /&gt;Belgian Damien Merenne has announced a plugin for Ruby on Rails that allows you to programatically keep track of a user&amp;#8217;s browsing history in your controllers.&lt;/p&gt;

&lt;p&gt;Once enabled, you can use the following methods in your actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;last_location&lt;/code&gt;: returns the last visited location, can be used with one numeric argument precising how many locations to go back in the history (1 by default),&lt;/li&gt;
&lt;li&gt;&lt;code&gt;redirect_back&lt;/code&gt;: redirect the user to the last location in history, it takes the same arguments as last_location,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;store_location&lt;/code&gt;: force storing of the current location in the history.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And it&amp;#8217;s simple enough to use. Just add a bit of code like this to your controllers:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;ApplicationController&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ActionController&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;
  &lt;span class="ident"&gt;history&lt;/span&gt; &lt;span class="symbol"&gt;:default&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://default.url.com/&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;,&lt;/span&gt; 
          &lt;span class="symbol"&gt;:max&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;10&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="http://blog.cosinux.org/pages/rails-history"&gt;Read about the Rails History Plugin&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 01 Jun 2006 16:48:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:b8e78b36-80b3-40bb-af6a-cbfc2a732435</guid>
      <author>Daniel Butler</author>
      <link>http://www.yup.com/articles/2006/06/01/rails-history-plugin</link>
      <category>Ruby on Rails</category>
      <category>plugin</category>
    </item>
  </channel>
</rss>
