<?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: How to alias and create a new named scope out of existing ones</title>
	<atom:link href="http://www.rngtng.com/2009/03/26/how-to-alias-and-create-a-new-named-scope-out-of-existing-ones/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rngtng.com/2009/03/26/how-to-alias-and-create-a-new-named-scope-out-of-existing-ones/</link>
	<description>Featuring Ruby, Rails, Web development, Arduino, Processing, Nabaztag and more...</description>
	<lastBuildDate>Tue, 15 May 2012 02:35:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: scragz</title>
		<link>http://www.rngtng.com/2009/03/26/how-to-alias-and-create-a-new-named-scope-out-of-existing-ones/comment-page-1/#comment-651</link>
		<dc:creator>scragz</dc:creator>
		<pubDate>Mon, 07 Feb 2011 03:17:43 +0000</pubDate>
		<guid isPermaLink="false">http://urangatang.wordpress.com/?p=8#comment-651</guid>
		<description>I wanted to just make some simple aliases like alias_method so I whipped this up:

module ActiveRecord
  class Base
    def self.alias_named_scope(alias_scope, original_scope)
      named_scope alias_scope, lambda { self.send(original_scope).scope(:find) }
    end
  end
end
</description>
		<content:encoded><![CDATA[<p>I wanted to just make some simple aliases like alias_method so I whipped this up:</p>
<p>module ActiveRecord<br />
  class Base<br />
    def self.alias_named_scope(alias_scope, original_scope)<br />
      named_scope alias_scope, lambda { self.send(original_scope).scope(:find) }<br />
    end<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Ongaro</title>
		<link>http://www.rngtng.com/2009/03/26/how-to-alias-and-create-a-new-named-scope-out-of-existing-ones/comment-page-1/#comment-529</link>
		<dc:creator>David Ongaro</dc:creator>
		<pubDate>Fri, 04 Jun 2010 12:05:38 +0000</pubDate>
		<guid isPermaLink="false">http://urangatang.wordpress.com/?p=8#comment-529</guid>
		<description>Nice. Even though just defining a method like

  def self.has_moo_and_foo
    has_moo. has_foo
  end

also works, I find the named_scope syntax more appealing, because one can scan the named scopes in one sight. (And they also show up in Fu.scopes).

When you define the scopes in the right order, the lambda gets superflous though. So

  named_scope :has_moo_and_foo, has_moo.has_foo.scope(:find)

is enough. But default_scope conditions are duplicated in this way (with or without lambda). Even though this doesn&#039;t might hurt it seems to be saver to just exclude them:

  named_scope :has_moo_and_foo, with_exclusive_scope { has_moo.has_foo.scope(:find) }</description>
		<content:encoded><![CDATA[<p>Nice. Even though just defining a method like</p>
<p>  def self.has_moo_and_foo<br />
    has_moo. has_foo<br />
  end</p>
<p>also works, I find the named_scope syntax more appealing, because one can scan the named scopes in one sight. (And they also show up in Fu.scopes).</p>
<p>When you define the scopes in the right order, the lambda gets superflous though. So</p>
<p>  named_scope :has_moo_and_foo, has_moo.has_foo.scope(:find)</p>
<p>is enough. But default_scope conditions are duplicated in this way (with or without lambda). Even though this doesn&#8217;t might hurt it seems to be saver to just exclude them:</p>
<p>  named_scope :has_moo_and_foo, with_exclusive_scope { has_moo.has_foo.scope(:find) }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Thompson</title>
		<link>http://www.rngtng.com/2009/03/26/how-to-alias-and-create-a-new-named-scope-out-of-existing-ones/comment-page-1/#comment-53</link>
		<dc:creator>Michael Thompson</dc:creator>
		<pubDate>Fri, 18 Sep 2009 08:09:53 +0000</pubDate>
		<guid isPermaLink="false">http://urangatang.wordpress.com/?p=8#comment-53</guid>
		<description>Thanks, this was useful. I had a bunch of anonymous named scopes I needed to chain together, but with OR, rather than AND. It was simple to create a new scope using the collection of #scope(:find)[:conditions] joined with &quot; OR &quot;.</description>
		<content:encoded><![CDATA[<p>Thanks, this was useful. I had a bunch of anonymous named scopes I needed to chain together, but with OR, rather than AND. It was simple to create a new scope using the collection of #scope(:find)[:conditions] joined with &#8221; OR &#8220;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

