Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Let Base.all use conditions etc like first/last

  • Loading branch information...
commit 0a6980f2dc6ef8b211323e0655f41702a4ce3eae 1 parent 850aba5
David Heinemeier Hansson authored
View
6 activerecord/lib/active_record/base.rb
@@ -532,6 +532,12 @@ def last(*args)
find(:last, *args)
end
+ # This is an alias for find(:all). You can pass in all the same arguments to this method as you can
+ # to find(:all)
+ def all(*args)
+ find(:all, *args)
+ end
+
#
# Executes a custom sql query against your database and returns all the results. The results will
# be returned as an array with columns requested encapsulated as attributes of the model you call
View
1  activerecord/lib/active_record/named_scope.rb
@@ -11,7 +11,6 @@ module NamedScope
def self.included(base)
base.class_eval do
extend ClassMethods
- named_scope :all
named_scope :scoped, lambda { |scope| scope }
end
end
View
4 activerecord/test/cases/base_test.rb
@@ -1630,6 +1630,10 @@ def test_find_last
def test_last
assert_equal Developer.find(:first, :order => 'id desc'), Developer.last
end
+
+ def test_all_with_conditions
+ assert_equal Developer.find(:all, :order => 'id desc'), Developer.all(:order => 'id desc')
+ end
def test_find_ordered_last
last = Developer.find :last, :order => 'developers.salary ASC'
Please sign in to comment.
Something went wrong with that request. Please try again.