aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/post.rb
diff options
context:
space:
mode:
authorDiego Algorta <diego@oboxodo.com>2009-02-13 03:07:39 -0300
committerrick <technoweenie@gmail.com>2009-02-25 09:21:08 -0800
commit0dd2f96f5c90f8abacb0fe0757ef7e5db4a4d501 (patch)
treec696bfc85598fa5a3ad1c5ba0db9636ab90f740a /activerecord/test/models/post.rb
parent92a30b0c88384feafc0da2864c01ff5c3a6f25ff (diff)
downloadrails-0dd2f96f5c90f8abacb0fe0757ef7e5db4a4d501.tar.gz
rails-0dd2f96f5c90f8abacb0fe0757ef7e5db4a4d501.tar.bz2
rails-0dd2f96f5c90f8abacb0fe0757ef7e5db4a4d501.zip
Fixed bug that makes named_scopes _forgot_ current scope
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 388fff8fba..374e536a5b 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -1,5 +1,7 @@
class Post < ActiveRecord::Base
named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'"
+ named_scope :ranked_by_comments, :order => "comments_count DESC"
+ named_scope :limit, lambda {|limit| {:limit => limit} }
named_scope :with_authors_at_address, lambda { |address| {
:conditions => [ 'authors.author_address_id = ?', address.id ],
:joins => 'JOIN authors ON authors.id = posts.author_id'
@@ -68,6 +70,10 @@ class Post < ActiveRecord::Base
:before_remove => lambda {|owner, reader| log(:removed, :before, reader.first_name) },
:after_remove => lambda {|owner, reader| log(:removed, :after, reader.first_name) }
+ def self.top(limit)
+ ranked_by_comments.limit(limit)
+ end
+
def self.reset_log
@log = []
end