aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/post.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-01-24 17:54:10 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-24 17:54:10 +0000
commitfe6ffce51dc16285094be49244b26591956c2dd6 (patch)
treef83e9fb9cde96e2e5b5d2e89ea9ae0333d2f0b9b /activerecord/test/models/post.rb
parentb2192888ab28b4cc36a54b5c918c6773de95a030 (diff)
downloadrails-fe6ffce51dc16285094be49244b26591956c2dd6.tar.gz
rails-fe6ffce51dc16285094be49244b26591956c2dd6.tar.bz2
rails-fe6ffce51dc16285094be49244b26591956c2dd6.zip
Make sure inner scope conditions get a preference over the outer ones
Diffstat (limited to 'activerecord/test/models/post.rb')
-rw-r--r--activerecord/test/models/post.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index e0d8be676a..388fff8fba 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -17,6 +17,12 @@ class Post < ActiveRecord::Base
has_one :last_comment, :class_name => 'Comment', :order => 'id desc'
+ named_scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} }
+ named_scope :with_very_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'VerySpecialComment'} }
+ named_scope :with_post, lambda {|post_id|
+ { :joins => :comments, :conditions => {:comments => {:post_id => post_id} } }
+ }
+
has_many :comments, :order => "body" do
def find_most_recent
find(:first, :order => "id DESC")