diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-07-27 17:27:47 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-07-27 17:27:47 +0100 |
commit | b658cf1198bbeb0fb702cd10c6f491cd90cedba0 (patch) | |
tree | e3163ecc180fd799659ab4d9579f91c5ff293f5a /activerecord/test/models | |
parent | 6a81ccd69d96f36f4322ef927191ab5a35e68d68 (diff) | |
download | rails-b658cf1198bbeb0fb702cd10c6f491cd90cedba0.tar.gz rails-b658cf1198bbeb0fb702cd10c6f491cd90cedba0.tar.bz2 rails-b658cf1198bbeb0fb702cd10c6f491cd90cedba0.zip |
Deprecate ActiveRecord::Base.scoped.
It doesn't serve much purpose now that ActiveRecord::Base.all returns a
Relation.
The code is moved to active_record_deprecated_finders.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/bulb.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/comment.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/developer.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 7 | ||||
-rw-r--r-- | activerecord/test/models/project.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/topic.rb | 6 |
6 files changed, 16 insertions, 15 deletions
diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb index 640e57555d..0dc2fdd8ae 100644 --- a/activerecord/test/models/bulb.rb +++ b/activerecord/test/models/bulb.rb @@ -8,7 +8,7 @@ class Bulb < ActiveRecord::Base after_initialize :record_scope_after_initialize def record_scope_after_initialize - @scope_after_initialize = self.class.scoped + @scope_after_initialize = self.class.all end after_initialize :record_attributes_after_initialize diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index 3e9f1b0635..4b2015fe01 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -4,7 +4,7 @@ class Comment < ActiveRecord::Base scope :not_again, -> { where("comments.body NOT LIKE '%again%'") } scope :for_first_post, -> { where(:post_id => 1) } scope :for_first_author, -> { joins(:post).where("posts.author_id" => 1) } - scope :created, -> { scoped } + scope :created, -> { all } belongs_to :post, :counter_cache => true has_many :ratings @@ -19,13 +19,13 @@ class Comment < ActiveRecord::Base end def self.search_by_type(q) - self.scoped(:where => ["#{QUOTED_TYPE} = ?", q]).all + where("#{QUOTED_TYPE} = ?", q) end def self.all_as_method all end - scope :all_as_scope, -> { scoped } + scope :all_as_scope, -> { all } end class SpecialComment < Comment diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb index 1caf8fca53..adf4c56294 100644 --- a/activerecord/test/models/developer.rb +++ b/activerecord/test/models/developer.rb @@ -2,20 +2,20 @@ require 'ostruct' module DeveloperProjectsAssociationExtension def find_most_recent - scoped(:order => "id DESC").first + order("id DESC").first end end module DeveloperProjectsAssociationExtension2 def find_least_recent - scoped(:order => "id ASC").first + order("id ASC").first end end class Developer < ActiveRecord::Base has_and_belongs_to_many :projects do def find_most_recent - scoped(:order => "id DESC").first + order("id DESC").first end end @@ -37,7 +37,7 @@ class Developer < ActiveRecord::Base :join_table => "developers_projects", :association_foreign_key => "project_id" do def find_least_recent - scoped(:order => "id ASC").first + order("id ASC").first end end diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 92038c76e5..9c5b7310ff 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -31,7 +31,7 @@ class Post < ActiveRecord::Base has_many :comments do def find_most_recent - scoped(:order => "id DESC").first + order("id DESC").first end def newest @@ -65,8 +65,9 @@ class Post < ActiveRecord::Base has_many :taggings, :as => :taggable has_many :tags, :through => :taggings do def add_joins_and_select - scoped(:select => 'tags.*, authors.id as author_id', - :joins => 'left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id').all + select('tags.*, authors.id as author_id') + .joins('left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id') + .to_a end end diff --git a/activerecord/test/models/project.rb b/activerecord/test/models/project.rb index c31750688b..6b53ead34d 100644 --- a/activerecord/test/models/project.rb +++ b/activerecord/test/models/project.rb @@ -23,7 +23,7 @@ class Project < ActiveRecord::Base def self.all_as_method all end - scope :all_as_scope, -> { scoped } + scope :all_as_scope, -> { all } end class SpecialProject < Project diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index fb27c9d4f0..4b27c16681 100644 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -1,5 +1,5 @@ class Topic < ActiveRecord::Base - scope :base, -> { scoped } + scope :base, -> { all } scope :written_before, lambda { |time| if time where 'written_on < ?', time @@ -8,13 +8,13 @@ class Topic < ActiveRecord::Base scope :approved, -> { where(:approved => true) } scope :rejected, -> { where(:approved => false) } - scope :scope_with_lambda, lambda { scoped } + scope :scope_with_lambda, lambda { all } scope :by_lifo, -> { where(:author_name => 'lifo') } scope :replied, -> { where 'replies_count > 0' } scope 'approved_as_string', -> { where(:approved => true) } - scope :anonymous_extension, -> { scoped } do + scope :anonymous_extension, -> { all } do def one 1 end |