mirror of
https://github.com/github/rails.git
synced 2026-02-19 02:14:20 -05:00
Let Base.all use conditions etc like first/last
This commit is contained in:
@@ -532,6 +532,12 @@ module ActiveRecord #:nodoc:
|
||||
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
|
||||
|
||||
@@ -11,7 +11,6 @@ module ActiveRecord
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
extend ClassMethods
|
||||
named_scope :all
|
||||
named_scope :scoped, lambda { |scope| scope }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1630,6 +1630,10 @@ class BasicsTest < ActiveRecord::TestCase
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user