<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Making Session Data Available to Models in Ruby on Rails</title>
	<atom:link href="http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/</link>
	<description>Musings of a software developer in Milwaukee, WI.</description>
	<lastBuildDate>Fri, 05 Mar 2010 11:50:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jason FB</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-16043</link>
		<dc:creator>Jason FB</dc:creator>
		<pubDate>Thu, 18 Feb 2010 17:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-16043</guid>
		<description>This is the best post I&#039;ve found about this issue -- a hotly debated topic. Just implemented this for the app I&#039;m working on and we found this solution to be the one we went with. It maintains abstraction while gets the job done.

One thing to note, in your ApplicationController you don&#039;t need to include UserInfo:

class ApplicationController &lt; ActionController::Base
  include UserInfo

The include statement is unnecessary and in fact will get in the way if you have another kind of authentication system (authlogic, restful-authentication) which is going to define a current_user method at the Controller level too. 

So I just took it out there (it is still necessary in the model of course).

(Since UserInfo.current_user is setting a class variable, all you need is the module loaded, not to mix it into your controller.)

If anyone sees a problem with this approach let me know.</description>
		<content:encoded><![CDATA[<p>This is the best post I&#8217;ve found about this issue &#8212; a hotly debated topic. Just implemented this for the app I&#8217;m working on and we found this solution to be the one we went with. It maintains abstraction while gets the job done.</p>
<p>One thing to note, in your ApplicationController you don&#8217;t need to include UserInfo:</p>
<p>class ApplicationController &lt; ActionController::Base<br />
  include UserInfo</p>
<p>The include statement is unnecessary and in fact will get in the way if you have another kind of authentication system (authlogic, restful-authentication) which is going to define a current_user method at the Controller level too. </p>
<p>So I just took it out there (it is still necessary in the model of course).</p>
<p>(Since UserInfo.current_user is setting a class variable, all you need is the module loaded, not to mix it into your controller.)</p>
<p>If anyone sees a problem with this approach let me know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Braxton Beyer</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-15892</link>
		<dc:creator>Braxton Beyer</dc:creator>
		<pubDate>Wed, 28 Oct 2009 01:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-15892</guid>
		<description>Could you achieve this same thing using Rails.cache? (http://www.highdots.com/forums/ruby-rails-talk/best-way-store-global-variable-285504.html)

What are the pros/cons of each method?</description>
		<content:encoded><![CDATA[<p>Could you achieve this same thing using Rails.cache? (<a href="http://www.highdots.com/forums/ruby-rails-talk/best-way-store-global-variable-285504.html" rel="nofollow">http://www.highdots.com/forums/ruby-rails-talk/best-way-store-global-variable-285504.html</a>)</p>
<p>What are the pros/cons of each method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yuanping</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-15602</link>
		<dc:creator>yuanping</dc:creator>
		<pubDate>Wed, 02 Sep 2009 05:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-15602</guid>
		<description>Thank you. This is exactly what I was looking for</description>
		<content:encoded><![CDATA[<p>Thank you. This is exactly what I was looking for</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prakash Teli</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-15552</link>
		<dc:creator>Prakash Teli</dc:creator>
		<pubDate>Wed, 15 Jul 2009 10:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-15552</guid>
		<description>Thank you. This is exactly what I was looking for. I tried using global variables first that was a bad idea. This is a much cleaner solution.</description>
		<content:encoded><![CDATA[<p>Thank you. This is exactly what I was looking for. I tried using global variables first that was a bad idea. This is a much cleaner solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivar Vasara</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-15076</link>
		<dc:creator>Ivar Vasara</dc:creator>
		<pubDate>Fri, 08 May 2009 23:03:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-15076</guid>
		<description>Alternatively, a good working example of using ActionController::Caching::Sweeper is the &lt;a href=&quot;http://github.com/jnunemaker/user_stamp/blob/93d38c83c18919220a83914e4ae5c930c2548ca8/lib/user_stamp.rb&quot; rel=&quot;nofollow&quot;&gt;user_stamp plugin&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Alternatively, a good working example of using ActionController::Caching::Sweeper is the <a href="http://github.com/jnunemaker/user_stamp/blob/93d38c83c18919220a83914e4ae5c930c2548ca8/lib/user_stamp.rb" rel="nofollow">user_stamp plugin</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cristian Livadaru</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-15011</link>
		<dc:creator>Cristian Livadaru</dc:creator>
		<pubDate>Thu, 16 Apr 2009 18:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-15011</guid>
		<description>what about using attr_accessor ? 
for example: 

&lt;code lang=&quot;ruby&quot;&gt;
class Person &lt; ActiveRecord::Base
  attr_accessor :change_user
  #..
end
&lt;/code&gt;

then you can access the data in the controller and assign the value from the session.</description>
		<content:encoded><![CDATA[<p>what about using attr_accessor ?<br />
for example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Person <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  attr_accessor <span style="color:#ff3333; font-weight:bold;">:change_user</span>
  <span style="color:#008000; font-style:italic;">#..</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>then you can access the data in the controller and assign the value from the session.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-14793</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Fri, 30 Jan 2009 23:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-14793</guid>
		<description>This is pretty nice.  Solves an interesting problem.  Just took a few minutes to wire it in.  Thanks!</description>
		<content:encoded><![CDATA[<p>This is pretty nice.  Solves an interesting problem.  Just took a few minutes to wire it in.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alejandro</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-14778</link>
		<dc:creator>Alejandro</dc:creator>
		<pubDate>Wed, 28 Jan 2009 21:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-14778</guid>
		<description>Hi, nice post!
Do you know if this works with FastCGI?
I tried it with WEBrick and it works, but in production I have FastCGI and I couldn&#039;t confirm it uses one thread per request.
Thanks!</description>
		<content:encoded><![CDATA[<p>Hi, nice post!<br />
Do you know if this works with FastCGI?<br />
I tried it with WEBrick and it works, but in production I have FastCGI and I couldn&#8217;t confirm it uses one thread per request.<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: magnum blog &#187; Blog Archive &#187; links for 2009-01-20</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-14618</link>
		<dc:creator>magnum blog &#187; Blog Archive &#187; links for 2009-01-20</dc:creator>
		<pubDate>Tue, 20 Jan 2009 17:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-14618</guid>
		<description>[...] Making Session Data Available to Models in Ruby on Rails &#124; Zorched / One Line Fix include UserInfo (tags: programming tutorial rails rubyonrails ruby security ror mongrel session sessions) [...]</description>
		<content:encoded><![CDATA[<p>[...] Making Session Data Available to Models in Ruby on Rails | Zorched / One Line Fix include UserInfo (tags: programming tutorial rails rubyonrails ruby security ror mongrel session sessions) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/comment-page-1/#comment-14445</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Sat, 10 Jan 2009 16:41:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.zorched.net/2007/05/29/making-session-data-available-to-models-in-ruby-on-rails/#comment-14445</guid>
		<description>Does anyone know whether Thread.current works with Passenger?</description>
		<content:encoded><![CDATA[<p>Does anyone know whether Thread.current works with Passenger?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
