aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-27 18:28:59 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-27 18:28:59 +0530
commitd6d0fe8c8f68529404d8186634f1f7b5f6f4b32c (patch)
treebc4bfb6e62ae6a97780d7fd9e07ac17af3ce79b2 /activerecord/lib/active_record/base.rb
parent59cf5e7bf293f30ef4984842a1bce0d63870fc69 (diff)
downloadrails-d6d0fe8c8f68529404d8186634f1f7b5f6f4b32c.tar.gz
rails-d6d0fe8c8f68529404d8186634f1f7b5f6f4b32c.tar.bz2
rails-d6d0fe8c8f68529404d8186634f1f7b5f6f4b32c.zip
Make Model.find(:first, ..) use relations
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb26
1 files changed, 2 insertions, 24 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 5ea1bc983e..0766dfe752 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -645,7 +645,7 @@ module ActiveRecord #:nodoc:
case args.first
when :first
- find_initial(options)
+ construct_finder_arel_with_includes(options).first
when :last
find_last(options)
when :all
@@ -1519,11 +1519,6 @@ module ActiveRecord #:nodoc:
end
private
- def find_initial(options)
- options.update(:limit => 1)
- find_every(options).first
- end
-
def find_last(options)
order = options[:order]
@@ -1540,7 +1535,7 @@ module ActiveRecord #:nodoc:
end
begin
- find_initial(options.merge({ :order => order }))
+ construct_finder_arel_with_includes(options).order(order).first
ensure
scope[:order] = original_scoped_order if original_scoped_order
end
@@ -1558,23 +1553,6 @@ module ActiveRecord #:nodoc:
}.join(',')
end
- def find_every(options)
- include_associations = merge_includes(scope(:find, :include), options[:include])
-
- if include_associations.any? && references_eager_loaded_tables?(options)
- records = find_with_associations(options)
- else
- records = find_by_sql(construct_finder_sql(options))
- if include_associations.any?
- preload_associations(records, include_associations)
- end
- end
-
- records.each { |record| record.readonly! } if options[:readonly]
-
- records
- end
-
# Finder methods must instantiate through this method to work with the
# single-table inheritance model that makes it possible to create
# objects of different types from the same table.