aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-04-27 11:42:22 +0100
committerJon Leighton <j@jonathanleighton.com>2012-04-27 11:42:50 +0100
commitdf6f971e3aedf8bb1ec318de95d7ce849e2c9c9e (patch)
treec18946036ddff7f38c92a9c4f8bff99bc6da49c9 /activerecord/test/models
parenta57b7842d0fcdcbcc567532d3a5c1f2628057a0d (diff)
downloadrails-df6f971e3aedf8bb1ec318de95d7ce849e2c9c9e.tar.gz
rails-df6f971e3aedf8bb1ec318de95d7ce849e2c9c9e.tar.bz2
rails-df6f971e3aedf8bb1ec318de95d7ce849e2c9c9e.zip
%s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other things
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/comment.rb2
-rw-r--r--activerecord/test/models/developer.rb8
-rw-r--r--activerecord/test/models/post.rb6
3 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index cf73c28ded..8ab4149ff7 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -19,7 +19,7 @@ class Comment < ActiveRecord::Base
end
def self.search_by_type(q)
- self.find(:all, :conditions => ["#{QUOTED_TYPE} = ?", q])
+ self.scoped(:conditions => ["#{QUOTED_TYPE} = ?", q]).all
end
def self.all_as_method
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index 7133094f5d..83482f4d07 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
- find(:first, :order => "id DESC")
+ scoped(:order => "id DESC").first
end
end
module DeveloperProjectsAssociationExtension2
def find_least_recent
- find(:first, :order => "id ASC")
+ scoped(:order => "id ASC").first
end
end
class Developer < ActiveRecord::Base
has_and_belongs_to_many :projects do
def find_most_recent
- find(:first, :order => "id DESC")
+ scoped(:order => "id DESC").first
end
end
@@ -37,7 +37,7 @@ class Developer < ActiveRecord::Base
:association_foreign_key => "project_id",
:extend => DeveloperProjectsAssociationExtension do
def find_least_recent
- find(:first, :order => "id ASC")
+ scoped(:order => "id ASC").first
end
end
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 18810f2de8..1aaf9a1b82 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
- find(:first, :order => "id DESC")
+ scoped(:order => "id DESC").first
end
def newest
@@ -64,8 +64,8 @@ class Post < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings do
def add_joins_and_select
- find :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'
+ 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
end
end