From a3683fd0e4980ae4926497ba7c7b7e8606f3e88e Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 8 Jul 2011 01:12:09 +0900 Subject: find(:all) => all --- activerecord/lib/active_record/associations.rb | 36 +++++++++++++------------- activerecord/lib/active_record/errors.rb | 2 +- activerecord/lib/active_record/fixtures.rb | 6 ++--- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 2cbfa42718..b23b51e832 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -191,7 +191,7 @@ module ActiveRecord # * Project#portfolio, Project#portfolio=(portfolio), Project#portfolio.nil? # * Project#project_manager, Project#project_manager=(project_manager), Project#project_manager.nil?, # * Project#milestones.empty?, Project#milestones.size, Project#milestones, Project#milestones<<(milestone), - # Project#milestones.delete(milestone), Project#milestones.find(milestone_id), Project#milestones.find(:all, options), + # Project#milestones.delete(milestone), Project#milestones.find(milestone_id), Project#milestones.all(options), # Project#milestones.build, Project#milestones.create # * Project#categories.empty?, Project#categories.size, Project#categories, Project#categories<<(category1), # Project#categories.delete(category1) @@ -669,7 +669,7 @@ module ActiveRecord # To iterate over these one hundred posts, we'll generate 201 database queries. Let's # first just optimize it for retrieving the author: # - # Post.find(:all, :include => :author).each do |post| + # Post.all(:include => :author).each do |post| # # This references the name of the +belongs_to+ association that also used the :author # symbol. After loading the posts, find will collect the +author_id+ from each one and load @@ -678,7 +678,7 @@ module ActiveRecord # # We can improve upon the situation further by referencing both associations in the finder with: # - # Post.find(:all, :include => [ :author, :comments ]).each do |post| + # Post.all(:include => [ :author, :comments ]).each do |post| # # This will load all comments with a single query. This reduces the total number of queries # to 3. More generally the number of queries will be 1 plus the number of associations @@ -686,7 +686,7 @@ module ActiveRecord # # To include a deep hierarchy of associations, use a hash: # - # Post.find(:all, :include => [ :author, { :comments => { :author => :gravatar } } ]).each do |post| + # Post.all(:include => [ :author, { :comments => { :author => :gravatar } } ]).each do |post| # # That'll grab not only all the comments but all their authors and gravatar pictures. # You can mix and match symbols, arrays and hashes in any combination to describe the @@ -720,7 +720,7 @@ module ActiveRecord # has_many :approved_comments, :class_name => 'Comment', :conditions => ['approved = ?', true] # end # - # Post.find(:all, :include => :approved_comments) + # Post.all(:include => :approved_comments) # # This will load posts and eager load the +approved_comments+ association, which contains # only those comments that have been approved. @@ -745,7 +745,7 @@ module ActiveRecord # # A call that tries to eager load the addressable model # - # Address.find(:all, :include => :addressable) + # Address.all(:include => :addressable) # # This will execute one query to load the addresses and load the addressables with one # query per addressable type. @@ -763,33 +763,33 @@ module ActiveRecord # second time, the table is aliased as #{reflection_name}_#{parent_table_name}. # Indexes are appended for any more successive uses of the table name. # - # Post.find :all, :joins => :comments + # Post.all :joins => :comments # # => SELECT ... FROM posts INNER JOIN comments ON ... - # Post.find :all, :joins => :special_comments # STI + # Post.all :joins => :special_comments # STI # # => SELECT ... FROM posts INNER JOIN comments ON ... AND comments.type = 'SpecialComment' - # Post.find :all, :joins => [:comments, :special_comments] # special_comments is the reflection name, posts is the parent table name + # Post.all :joins => [:comments, :special_comments] # special_comments is the reflection name, posts is the parent table name # # => SELECT ... FROM posts INNER JOIN comments ON ... INNER JOIN comments special_comments_posts # # Acts as tree example: # - # TreeMixin.find :all, :joins => :children + # TreeMixin.all :joins => :children # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... - # TreeMixin.find :all, :joins => {:children => :parent} + # TreeMixin.all :joins => {:children => :parent} # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... # INNER JOIN parents_mixins ... - # TreeMixin.find :all, :joins => {:children => {:parent => :children}} + # TreeMixin.all :joins => {:children => {:parent => :children}} # # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ... # INNER JOIN parents_mixins ... # INNER JOIN mixins childrens_mixins_2 # # Has and Belongs to Many join tables use the same idea, but add a _join suffix: # - # Post.find :all, :joins => :categories + # Post.all :joins => :categories # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... - # Post.find :all, :joins => {:categories => :posts} + # Post.all :joins => {:categories => :posts} # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories - # Post.find :all, :joins => {:categories => {:posts => :categories}} + # Post.all :joins => {:categories => {:posts => :categories}} # # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ... # INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories # INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2 @@ -797,9 +797,9 @@ module ActiveRecord # If you wish to specify your own custom joins using a :joins option, those table # names will take precedence over the eager associations: # - # Post.find :all, :joins => :comments, :joins => "inner join comments ..." + # Post.all :joins => :comments, :joins => "inner join comments ..." # # => SELECT ... FROM posts INNER JOIN comments_posts ON ... INNER JOIN comments ... - # Post.find :all, :joins => [:comments, :special_comments], :joins => "inner join comments ..." + # Post.all :joins => [:comments, :special_comments], :joins => "inner join comments ..." # # => SELECT ... FROM posts INNER JOIN comments comments_posts ON ... # INNER JOIN comments special_comments_posts ... # INNER JOIN comments ... @@ -1031,7 +1031,7 @@ module ActiveRecord # === Example # # Example: A Firm class declares has_many :clients, which will add: - # * Firm#clients (similar to Clients.find :all, :conditions => ["firm_id = ?", id]) + # * Firm#clients (similar to Clients.all :conditions => ["firm_id = ?", id]) # * Firm#clients<< # * Firm#clients.delete # * Firm#clients= diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index ea1709cb1f..3bd2ed8f1b 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -87,7 +87,7 @@ module ActiveRecord # # For example, in # - # Location.find :all, :conditions => ["lat = ? AND lng = ?", 53.7362] + # Location.all :conditions => ["lat = ? AND lng = ?", 53.7362] # # two placeholders are given but only one variable to fill them. class PreparedStatementInvalid < ActiveRecordError diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 819743a361..3f36dcde14 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -149,13 +149,13 @@ class FixturesFileNotFound < StandardError; end # self.use_transactional_fixtures = true # # test "godzilla" do -# assert !Foo.find(:all).empty? +# assert !Foo.all.empty? # Foo.destroy_all -# assert Foo.find(:all).empty? +# assert Foo.all.empty? # end # # test "godzilla aftermath" do -# assert !Foo.find(:all).empty? +# assert !Foo.all.empty? # end # end # -- cgit v1.2.3