<?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: Inverting Permission-Based Filtering with named_scope</title>
	<atom:link href="http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/</link>
	<description>A delicious blend of Ruby and Rails...</description>
	<lastBuildDate>Sun, 03 Jan 2010 16:28:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Justin Palmer</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-2110</link>
		<dc:creator>Justin Palmer</dc:creator>
		<pubDate>Thu, 12 Mar 2009 03:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-2110</guid>
		<description>Hi Ben,

Thanks, that worked perfect.  I used:

named_scope :by_company, {:conditions =&gt; COMPANY_ID.nil? ? {} : {:company_id =&gt; COMPANY_ID} }

I see now where my syntax was wrong.  I tried something like above, but kept getting errors.

I appreciate the help.

Regards,

Justin</description>
		<content:encoded><![CDATA[<p>Hi Ben,</p>
<p>Thanks, that worked perfect.  I used:</p>
<p>named_scope :by_company, {:conditions =&gt; COMPANY_ID.nil? ? {} : {:company_id =&gt; COMPANY_ID} }</p>
<p>I see now where my syntax was wrong.  I tried something like above, but kept getting errors.</p>
<p>I appreciate the help.</p>
<p>Regards,</p>
<p>Justin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benhughes</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-2109</link>
		<dc:creator>benhughes</dc:creator>
		<pubDate>Thu, 12 Mar 2009 03:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-2109</guid>
		<description>Try this:

named_scope :by_company, lambda { {:conditions =&gt; COMPANY_ID.nil? ? {} : {:company_id =&gt; COMPANY_ID} } }

However if COMPANY_ID really is a constant (not sure how or why you are using it this way...) you don&#039;t really even need the lambda since lazy evaluation is unnecessary:

named_scope :by_company, {:conditions =&gt; COMPANY_ID.nil? ? {} : {:company_id =&gt; COMPANY_ID} }</description>
		<content:encoded><![CDATA[<p>Try this:</p>
<p>named_scope :by_company, lambda { {:conditions => COMPANY_ID.nil? ? {} : {:company_id => COMPANY_ID} } }</p>
<p>However if COMPANY_ID really is a constant (not sure how or why you are using it this way&#8230;) you don&#8217;t really even need the lambda since lazy evaluation is unnecessary:</p>
<p>named_scope :by_company, {:conditions => COMPANY_ID.nil? ? {} : {:company_id => COMPANY_ID} }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Palmer</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-2108</link>
		<dc:creator>Justin Palmer</dc:creator>
		<pubDate>Thu, 12 Mar 2009 03:13:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-2108</guid>
		<description>Sorry, I forgot to give the error:

cet_named_scope.rb:13: odd number list for Hash

Line 13 is the &#039;end&#039; of the case statement.</description>
		<content:encoded><![CDATA[<p>Sorry, I forgot to give the error:</p>
<p>cet_named_scope.rb:13: odd number list for Hash</p>
<p>Line 13 is the &#8216;end&#8217; of the case statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Palmer</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-2107</link>
		<dc:creator>Justin Palmer</dc:creator>
		<pubDate>Thu, 12 Mar 2009 03:11:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-2107</guid>
		<description>Hey nice template by the way :)

I have the following code that is now working as expected.  Do you have any ideas?

named_scope :by_company, lambda{{
      case
      when COMPANY_ID.nil? then false
      else {:conditions =&gt; [&#039;company_id = ?&#039;, COMPANY_ID]}
      end
  }}

Any help would be greatly appreciated.

Thanks,

Justin</description>
		<content:encoded><![CDATA[<p>Hey nice template by the way <img src='http://www.railsgarden.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I have the following code that is now working as expected.  Do you have any ideas?</p>
<p>named_scope :by_company, lambda{{<br />
      case<br />
      when COMPANY_ID.nil? then false<br />
      else {:conditions =&gt; ['company_id = ?', COMPANY_ID]}<br />
      end<br />
  }}</p>
<p>Any help would be greatly appreciated.</p>
<p>Thanks,</p>
<p>Justin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ash McKenzie</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-1685</link>
		<dc:creator>Ash McKenzie</dc:creator>
		<pubDate>Tue, 23 Dec 2008 23:11:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-1685</guid>
		<description>Legend, thanks for this hot tip.. saved me at least 10 lines of code!</description>
		<content:encoded><![CDATA[<p>Legend, thanks for this hot tip.. saved me at least 10 lines of code!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/comment-page-1/#comment-767</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sat, 12 Jul 2008 19:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.railsgarden.com/2008/07/05/inverting-permission-based-filtering-with-named_scope/#comment-767</guid>
		<description>cool beans :D</description>
		<content:encoded><![CDATA[<p>cool beans <img src='http://www.railsgarden.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
