<?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: NamedScopeBehavior upgrade</title>
	<atom:link href="http://codetunes.com/2008/09/15/namedscopebehavior-upgrade/feed/" rel="self" type="application/rss+xml" />
	<link>http://codetunes.com/2008/09/15/namedscopebehavior-upgrade/</link>
	<description>Web applications, software engineering, Ruby on Rails, Cake PHP, JavaScript, etc.</description>
	<pubDate>Fri, 12 Mar 2010 07:07:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Michał Szajbe</title>
		<link>http://codetunes.com/2008/09/15/namedscopebehavior-upgrade/comment-page-1/#comment-939</link>
		<dc:creator>Michał Szajbe</dc:creator>
		<pubDate>Tue, 16 Sep 2008 19:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=64#comment-939</guid>
		<description>Well, I didn't look at it that way, but I think it could work to some extent :)

Assuming that Comment belongsTo many commentable models (Article being one of them), you could do:
&lt;pre lang="php"&gt;
class Comment extends AppModel {
  var $actsAs = array(
    'NamedScope' =&gt; array(
      'promotedArticles' =&gt; array(
        'Comment.model' =&gt; 'Article',
        'Article.promoted' =&gt; 1
      )
    )
  );
}
&lt;/pre&gt;
Such scope would find all comments to promoted articles. 

Scope's conditions are copied to find query without any modifications so it is OK to have multi-model conditions in Comment's model named scope.

Of course you still need some support for polymorphism before. I believie that &lt;a href="http://bakery.cakephp.org/articles/view/polymorphic-behavior" rel="nofollow"&gt;PolymorphicBehavior&lt;/a&gt; or something similar would be fine.</description>
		<content:encoded><![CDATA[<p>Well, I didn&#8217;t look at it that way, but I think it could work to some extent :)</p>
<p>Assuming that Comment belongsTo many commentable models (Article being one of them), you could do:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Comment <span style="color: #000000; font-weight: bold;">extends</span> AppModel <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$actsAs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="">'NamedScope'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="">'promotedArticles'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="">'Comment.model'</span> <span style="color: #339933;">=&gt;</span> <span style="">'Article'</span><span style="color: #339933;">,</span>
        <span style="">'Article.promoted'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
      <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Such scope would find all comments to promoted articles. </p>
<p>Scope&#8217;s conditions are copied to find query without any modifications so it is OK to have multi-model conditions in Comment&#8217;s model named scope.</p>
<p>Of course you still need some support for polymorphism before. I believie that <a href="http://bakery.cakephp.org/articles/view/polymorphic-behavior" rel="nofollow">PolymorphicBehavior</a> or something similar would be fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucian Lature</title>
		<link>http://codetunes.com/2008/09/15/namedscopebehavior-upgrade/comment-page-1/#comment-938</link>
		<dc:creator>Lucian Lature</dc:creator>
		<pubDate>Mon, 15 Sep 2008 08:26:56 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=64#comment-938</guid>
		<description>Could you use that behavior as an emulator for polymorphism?...</description>
		<content:encoded><![CDATA[<p>Could you use that behavior as an emulator for polymorphism?&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
