aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-01-29 22:33:09 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-29 22:33:09 +0000
commit20d850dac78fc11512a6ad9f3d2ad397daac3e87 (patch)
treed982ec813560600d21edfe3ad1597d2c83af1df1 /activerecord/test/models
parent6932ae4b2978de6771e6d1c84cfc3595cf9d8bab (diff)
parentb3bc4fa5e02e71a992f8a432757548c762f0aad8 (diff)
downloadrails-20d850dac78fc11512a6ad9f3d2ad397daac3e87.tar.gz
rails-20d850dac78fc11512a6ad9f3d2ad397daac3e87.tar.bz2
rails-20d850dac78fc11512a6ad9f3d2ad397daac3e87.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/post.rb6
-rw-r--r--activerecord/test/models/topic.rb2
2 files changed, 8 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")
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 39ca1bf42a..08bb24ed03 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -4,6 +4,8 @@ class Topic < ActiveRecord::Base
{ :conditions => ['written_on < ?', time] }
}
named_scope :approved, :conditions => {:approved => true}
+ named_scope :rejected, :conditions => {:approved => false}
+
named_scope :by_lifo, :conditions => {:author_name => 'lifo'}
named_scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}}