aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/acts/list.rb9
-rw-r--r--activerecord/lib/active_record/acts/nested_set.rb8
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
-rwxr-xr-xactiverecord/lib/active_record/base.rb14
-rwxr-xr-xactiverecord/lib/active_record/callbacks.rb2
-rwxr-xr-xactiverecord/lib/active_record/fixtures.rb6
-rwxr-xr-xactiverecord/lib/active_record/validations.rb4
7 files changed, 21 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/acts/list.rb b/activerecord/lib/active_record/acts/list.rb
index eb3993a92b..6c908c88a4 100644
--- a/activerecord/lib/active_record/acts/list.rb
+++ b/activerecord/lib/active_record/acts/list.rb
@@ -135,14 +135,14 @@ module ActiveRecord
def higher_item
return nil unless in_list?
- self.class.find_first(
+ self.class.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
)
end
def lower_item
return nil unless in_list?
- self.class.find_first(
+ self.class.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
)
end
@@ -169,10 +169,7 @@ module ActiveRecord
end
def bottom_item
- self.class.find_first(
- "#{scope_condition} ",
- "#{position_column} DESC"
- )
+ self.class.find(:first, :conditions => scope_condition, :order => "#{position_column} DESC")
end
def assume_bottom_position
diff --git a/activerecord/lib/active_record/acts/nested_set.rb b/activerecord/lib/active_record/acts/nested_set.rb
index 0202ac65b4..cc120cad4b 100644
--- a/activerecord/lib/active_record/acts/nested_set.rb
+++ b/activerecord/lib/active_record/acts/nested_set.rb
@@ -181,17 +181,17 @@ module ActiveRecord
# Returns a set of itself and all of it's nested children
def full_set
- self.class.find_all( "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} and #{self[right_col_name]})" )
+ self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} and #{self[right_col_name]})" )
end
# Returns a set of all of it's children and nested children
def all_children
- self.class.find_all( "#{scope_condition} AND (#{left_col_name} > #{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})" )
+ self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} > #{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})" )
end
# Returns a set of only this entries immediate children
def direct_children
- self.class.find_all( "#{scope_condition} and #{parent_column} = #{self.id}")
+ self.class.find(:all, :conditions => "#{scope_condition} and #{parent_column} = #{self.id}")
end
# Prunes a branch off of the tree, shifting all of the elements on the right
@@ -209,4 +209,4 @@ module ActiveRecord
end
end
end
-end \ No newline at end of file
+end
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 9dba33dfd9..d82d58b94c 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -304,7 +304,7 @@ module ActiveRecord
# with +attributes+ and linked to this object through a foreign key and that has already been saved (if it passed the validation).
#
# Example: An Account class declares <tt>has_one :beneficiary</tt>, which will add:
- # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find_first "account_id = #{id}"</tt>)
+ # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find(:first, :conditions => "account_id = #{id}")</tt>)
# * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>)
# * <tt>Account#beneficiary.nil?</tt>
# * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>)
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 5535f224c8..7e2acb5acf 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -79,11 +79,11 @@ module ActiveRecord #:nodoc:
#
# User < ActiveRecord::Base
# def self.authenticate_unsafely(user_name, password)
- # find_first("user_name = '#{user_name}' AND password = '#{password}'")
+ # find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'")
# end
#
# def self.authenticate_safely(user_name, password)
- # find_first([ "user_name = ? AND password = ?", user_name, password ])
+ # find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ])
# end
# end
#
@@ -362,7 +362,7 @@ module ActiveRecord #:nodoc:
end
end
- # Works like find_all, but requires a complete SQL string. Examples:
+ # Works like find(:all), but requires a complete SQL string. Examples:
# Post.find_by_sql "SELECT p.*, c.author FROM posts p, comments c WHERE p.id = c.post_id"
# Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
def find_by_sql(sql)
@@ -426,7 +426,7 @@ module ActiveRecord #:nodoc:
# the destroy method. Example:
# Person.destroy_all "last_login < '2004-04-04'"
def destroy_all(conditions = nil)
- find_all(conditions).each { |object| object.destroy }
+ find(:all, :conditions => conditions).each { |object| object.destroy }
end
# Deletes all the records that matches the +condition+ without instantiating the objects first (and hence not
@@ -679,7 +679,7 @@ module ActiveRecord #:nodoc:
# Project.benchmark("Creating project") do
# project = Project.create("name" => "stuff")
# project.create_manager("name" => "David")
- # project.milestones << Milestone.find_all
+ # project.milestones << Milestone.find(:all)
# end
def benchmark(title)
result = nil
@@ -777,8 +777,8 @@ module ActiveRecord #:nodoc:
end
# Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into
- # find_first(["user_name = ?", user_name]) and find_first(["user_name = ? AND password = ?", user_name, password]) respectively. Also works
- # for find_all, but using find_all_by_amount(50) that are turned into find_all(["amount = ?", 50]).
+ # find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])
+ # respectively. Also works for find(:all), but using find_all_by_amount(50) that are turned into find(:all, :conditions => ["amount = ?", 50]).
#
# It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
# is actually find_all_by_amount(amount, options).
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 57745b344e..8e95502e56 100755
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -153,7 +153,7 @@ module ActiveRecord
#
# == The after_find and after_initialize exceptions
#
- # Because after_find and after_initialize is called for each object instantiated found by a finder, such as Base.find_all, we've had
+ # Because after_find and after_initialize is called for each object instantiated found by a finder, such as Base.find(:all), we've had
# to implement a simple performance constraint (50% more speed on a simple test case). Unlike all the other callbacks, after_find and
# after_initialize will only be run if an explicit implementation is defined (<tt>def after_find</tt>). In that case, all of the
# callback types will be called.
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 3c43ab7636..47928201c7 100755
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -169,13 +169,13 @@ require 'csv'
# fixtures :foos
#
# def test_godzilla
-# assert !Foo.find_all.emtpy?
+# assert !Foo.find(:all).empty?
# Foo.destroy_all
-# assert Foo.find_all.emtpy?
+# assert Foo.find(:all).empty?
# end
#
# def test_godzilla_aftermath
-# assert !Foo.find_all.emtpy?
+# assert !Foo.find(:all).empty?
# end
# end
#
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index e42b306e10..f455b97e0a 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -465,11 +465,11 @@ module ActiveRecord
if scope = configuration[:scope]
validates_each(attr_names,configuration) do |record, attr_name, value|
- record.errors.add(attr_name, configuration[:message]) if record.class.find_first(record.new_record? ? ["#{attr_name} = ? AND #{scope} = ?", record.send(attr_name), record.send(scope)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ? AND #{scope} = ?", record.send(attr_name), record.send(:id), record.send(scope)])
+ record.errors.add(attr_name, configuration[:message]) if record.class.find(:first, :conditions => (record.new_record? ? ["#{attr_name} = ? AND #{scope} = ?", record.send(attr_name), record.send(scope)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ? AND #{scope} = ?", record.send(attr_name), record.send(:id), record.send(scope)]))
end
else
validates_each(attr_names,configuration) do |record, attr_name, value|
- record.errors.add(attr_name, configuration[:message]) if record.class.find_first(record.new_record? ? ["#{attr_name} = ?", record.send(attr_name)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ?", record.send(attr_name), record.send(:id) ] )
+ record.errors.add(attr_name, configuration[:message]) if record.class.find(:first, :conditions => (record.new_record? ? ["#{attr_name} = ?", record.send(attr_name)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ?", record.send(attr_name), record.send(:id) ] ))
end
end
end