aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/post.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-04-17 20:47:52 +0100
committerJon Leighton <j@jonathanleighton.com>2011-04-17 20:47:52 +0100
commit256b363eeecf6d0fb896aabd3fc619e200a5062c (patch)
treec8dfbb127ceb2c13786d5206807e0c54d4ab0131 /activerecord/test/models/post.rb
parentd1f10e74caaedbc853d0f875d8e2a2ac16899fa0 (diff)
downloadrails-256b363eeecf6d0fb896aabd3fc619e200a5062c.tar.gz
rails-256b363eeecf6d0fb896aabd3fc619e200a5062c.tar.bz2
rails-256b363eeecf6d0fb896aabd3fc619e200a5062c.zip
Revert "Deprecate defining scopes with a callable (lambda, proc, etc) via the scope class method. Just define a class method yourself instead."
This reverts commit f0e198bfa1e3f9689e0cde1d194a44027fc90b3c. Conflicts: activerecord/test/models/post.rb
Diffstat (limited to 'activerecord/test/models/post.rb')
-rw-r--r--activerecord/test/models/post.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index a91c10276b..34cea60053 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -8,13 +8,12 @@ class Post < ActiveRecord::Base
scope :containing_the_letter_a, where("body LIKE '%a%'")
scope :ranked_by_comments, order("comments_count DESC")
- def self.limit_by(l)
- limit(l)
- end
-
- def self.with_authors_at_address(address)
- where('authors.author_address_id = ?', address.id).joins('JOIN authors ON authors.id = posts.author_id')
- end
+ scope :limit_by, lambda {|l| limit(l) }
+ scope :with_authors_at_address, lambda { |address| {
+ :conditions => [ 'authors.author_address_id = ?', address.id ],
+ :joins => 'JOIN authors ON authors.id = posts.author_id'
+ }
+ }
belongs_to :author do
def greeting
@@ -29,10 +28,9 @@ class Post < ActiveRecord::Base
scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} }
scope :with_very_special_comments, joins(:comments).where(:comments => {:type => 'VerySpecialComment'})
-
- def self.with_post(post_id)
- joins(:comments).where(:comments => { :post_id => post_id })
- end
+ scope :with_post, lambda {|post_id|
+ { :joins => :comments, :conditions => {:comments => {:post_id => post_id} } }
+ }
has_many :comments do
def find_most_recent