<?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: Recipe: Make request environment available to models in Rails</title>
	<atom:link href="http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/</link>
	<description>Jo Hund's software engineering blog</description>
	<lastBuildDate>Thu, 19 Aug 2010 12:37:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Logging in Ruby on Rails &#124; Rohit&#39;s Blog</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-220</link>
		<dc:creator>Logging in Ruby on Rails &#124; Rohit&#39;s Blog</dc:creator>
		<pubDate>Thu, 19 Aug 2010 12:37:37 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-220</guid>
		<description>[...] You can get the User.current by using the Thread class provided by Rails. A detailed version of this is available here. [...]</description>
		<content:encoded><![CDATA[<p>[...] You can get the User.current by using the Thread class provided by Rails. A detailed version of this is available here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LeipeLeon</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-165</link>
		<dc:creator>LeipeLeon</dc:creator>
		<pubDate>Fri, 18 Dec 2009 17:05:34 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-165</guid>
		<description>hmm.... 

seems to me that Thread.current is the thread of the rails process.

what about when 2 different users update simultaneously?</description>
		<content:encoded><![CDATA[<p>hmm&#8230;. </p>
<p>seems to me that Thread.current is the thread of the rails process.</p>
<p>what about when 2 different users update simultaneously?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Braxton Beyer</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-158</link>
		<dc:creator>Braxton Beyer</dc:creator>
		<pubDate>Wed, 28 Oct 2009 01:53:57 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-158</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: James Bebbington</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-151</link>
		<dc:creator>James Bebbington</dc:creator>
		<pubDate>Thu, 15 Oct 2009 11:34:14 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-151</guid>
		<description>Just adding a couple of manual trackbacks that are worth checking out:

http://stackoverflow.com/questions/1568218/access-to-currentuser-from-within-a-model-in-ruby-on-rails

http://www.pluitsolutions.com/2006/08/15/rails-auto-assign-created-by-and-updated-by/#comments</description>
		<content:encoded><![CDATA[<p>Just adding a couple of manual trackbacks that are worth checking out:</p>
<p><a href="http://stackoverflow.com/questions/1568218/access-to-currentuser-from-within-a-model-in-ruby-on-rails" rel="nofollow">http://stackoverflow.com/questions/1568218/access-to-currentuser-from-within-a-model-in-ruby-on-rails</a></p>
<p><a href="http://www.pluitsolutions.com/2006/08/15/rails-auto-assign-created-by-and-updated-by/#comments" rel="nofollow">http://www.pluitsolutions.com/2006/08/15/rails-auto-assign-created-by-and-updated-by/#comments</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ginty</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-126</link>
		<dc:creator>ginty</dc:creator>
		<pubDate>Tue, 03 Mar 2009 16:19:52 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-126</guid>
		<description>@Jo: Yep I agree, definitely part of the business logic and this definitely provides the means to put it where it belongs.

Thanks for the reply, I&#039;m converting my app over to something like this as we speak.

I plan to do a slight variation on your approach and only access my models from the controller via new methods Model.all_available (replacing find_all from the controller) and Model.get (replacing find(x)).

Then within these I will put the permission checks to return only what the current user is entitled to.

Cheers!</description>
		<content:encoded><![CDATA[<p>@Jo: Yep I agree, definitely part of the business logic and this definitely provides the means to put it where it belongs.</p>
<p>Thanks for the reply, I&#8217;m converting my app over to something like this as we speak.</p>
<p>I plan to do a slight variation on your approach and only access my models from the controller via new methods Model.all_available (replacing find_all from the controller) and Model.get (replacing find(x)).</p>
<p>Then within these I will put the permission checks to return only what the current user is entitled to.</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jo Hund</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-125</link>
		<dc:creator>Jo Hund</dc:creator>
		<pubDate>Tue, 03 Mar 2009 05:22:52 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-125</guid>
		<description>@ginty: Yes, I use this approach in production. I had a quick conversation with lifo on his blog about this. It feels a bit dirty. Global state. Not very object oriented. I am still wrestling with this. I believe permissions need to be delegated to the model. I don&#039;t care about MVC in this case. In a Graphics software, you do a lot of presentation work in the model, because that is the main concern of the software. So in a multi user web application, permissions are part of business logic and should be handled in the model.

The challenge is to give the model access to the current user. There are other solutions (sweepers), but using those for permissions feels just as much like a hack.

I am looking at other MVC implementations for inspiration. E.g. OS X software. What is Cocoa&#039;s way of handling this? I didn&#039;t dig very deep, however it seemed like you get get to the current user via a global accessor.</description>
		<content:encoded><![CDATA[<p>@ginty: Yes, I use this approach in production. I had a quick conversation with lifo on his blog about this. It feels a bit dirty. Global state. Not very object oriented. I am still wrestling with this. I believe permissions need to be delegated to the model. I don&#8217;t care about MVC in this case. In a Graphics software, you do a lot of presentation work in the model, because that is the main concern of the software. So in a multi user web application, permissions are part of business logic and should be handled in the model.</p>
<p>The challenge is to give the model access to the current user. There are other solutions (sweepers), but using those for permissions feels just as much like a hack.</p>
<p>I am looking at other MVC implementations for inspiration. E.g. OS X software. What is Cocoa&#8217;s way of handling this? I didn&#8217;t dig very deep, however it seemed like you get get to the current user via a global accessor.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ginty</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-124</link>
		<dc:creator>ginty</dc:creator>
		<pubDate>Tue, 03 Mar 2009 05:12:37 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-124</guid>
		<description>This is great stuff, thanks for that and your other related post.

Are you currently running this in production?

I&#039;m just slightly nervous (but without a good reason) given some of the discussion about the use of Thread.current in some way being a hack.

I really don&#039;t believe there is a better solution though, it makes so much sense to put the gatekeeper in the model, and it seems to be a violation of MVC to have to put that responsibility in the controller.</description>
		<content:encoded><![CDATA[<p>This is great stuff, thanks for that and your other related post.</p>
<p>Are you currently running this in production?</p>
<p>I&#8217;m just slightly nervous (but without a good reason) given some of the discussion about the use of Thread.current in some way being a hack.</p>
<p>I really don&#8217;t believe there is a better solution though, it makes so much sense to put the gatekeeper in the model, and it seems to be a violation of MVC to have to put that responsibility in the controller.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yawningman</title>
		<link>http://clearcove.ca/blog/2008/08/recipe-make-request-environment-available-to-models-in-rails/comment-page-1/#comment-99</link>
		<dc:creator>yawningman</dc:creator>
		<pubDate>Sat, 20 Dec 2008 09:47:23 +0000</pubDate>
		<guid isPermaLink="false">http://clearcove.ca/?p=273#comment-99</guid>
		<description>Thanks for this info, it was just what I needed to solve a similar problem of needing to store variables that where unique per request from within a rails plugin.</description>
		<content:encoded><![CDATA[<p>Thanks for this info, it was just what I needed to solve a similar problem of needing to store variables that where unique per request from within a rails plugin.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.223 seconds -->
