<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rails code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 19:14:47 GMT</pubDate>
    <description>DZone Snippets: rails code</description>
    <item>
      <title>A caching current user method call</title>
      <link>http://snippets.dzone.com/posts/show/4922</link>
      <description>A simple method that returns the current user and caches the result to reduce database hits.  This assumes you're storing user information in User and that the current user is identified by the session variable user_id.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class ApplicationController &lt; ActionController::Base&lt;br /&gt;  def current_user&lt;br /&gt;    session[:user_id] ? @current_user ||= User.find(session[:user_id]) : nil&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 24 Dec 2007 03:19:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4922</guid>
      <author>mgreenly (Michael Greenly)</author>
    </item>
  </channel>
</rss>
