aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2008-10-03 13:55:35 +0200
committerMichael Koziarski <michael@koziarski.com>2008-10-03 21:28:11 +0200
commit8d337e9ec2e25007d557150dbe7557ab3c3bd05f (patch)
tree35bc7945e1b9230a988238a7bdbbbd01e9069314 /activerecord/lib/active_record
parente69b506abd40222c87be28398c5191db160740cb (diff)
downloadrails-8d337e9ec2e25007d557150dbe7557ab3c3bd05f.tar.gz
rails-8d337e9ec2e25007d557150dbe7557ab3c3bd05f.tar.bz2
rails-8d337e9ec2e25007d557150dbe7557ab3c3bd05f.zip
Dynamic finders should use the ActiveRecord::Base::find method instead of ::find_initial, :find_last, and ::find_all.
This is so when people override ActiveRecord::Base::find, the new ::find method will also be invoked by the dynamic finders. Associations for instance do go through ::find, so this makes it more consistent. Also removed the unnecessary deprecation silence blocks. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1162 state:committed]
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb8
-rw-r--r--activerecord/lib/active_record/dynamic_finder_match.rb8
2 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 69ea155ace..3e8c573d09 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1724,10 +1724,10 @@ module ActiveRecord #:nodoc:
#{'result = ' if bang}if options[:conditions]
with_scope(:find => finder_options) do
- ActiveSupport::Deprecation.silence { send(:#{finder}, options) }
+ find(:#{finder}, options)
end
else
- ActiveSupport::Deprecation.silence { send(:#{finder}, options.merge(finder_options)) }
+ find(:#{finder}, options.merge(finder_options))
end
#{'result || raise(RecordNotFound)' if bang}
end
@@ -1750,9 +1750,9 @@ module ActiveRecord #:nodoc:
options = { :conditions => find_attributes }
set_readonly_option!(options)
- record = find_initial(options)
+ record = find(:first, options)
- if record.nil?
+ if record.nil?
record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) }
#{'yield(record) if block_given?'}
#{'record.save' if instantiator == :create}
diff --git a/activerecord/lib/active_record/dynamic_finder_match.rb b/activerecord/lib/active_record/dynamic_finder_match.rb
index f4a5712981..8f9f05ce36 100644
--- a/activerecord/lib/active_record/dynamic_finder_match.rb
+++ b/activerecord/lib/active_record/dynamic_finder_match.rb
@@ -6,11 +6,11 @@ module ActiveRecord
end
def initialize(method)
- @finder = :find_initial
+ @finder = :first
case method.to_s
when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/
- @finder = :find_last if $1 == 'last_by'
- @finder = :find_every if $1 == 'all_by'
+ @finder = :last if $1 == 'last_by'
+ @finder = :all if $1 == 'all_by'
names = $2
when /^find_by_([_a-zA-Z]\w*)\!$/
@bang = true
@@ -31,7 +31,7 @@ module ActiveRecord
end
def instantiator?
- @finder == :find_initial && !@instantiator.nil?
+ @finder == :first && !@instantiator.nil?
end
def bang?