Changeset 9085
- Timestamp:
- 03/24/08 19:59:22 (2 months ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/test/cases/base_test.rb (modified) (1 diff)
- trunk/activerecord/test/cases/finder_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r9084 r9085 1 1 *SVN* 2 2 3 * Added ActiveRecord#Base.all/first/last as aliases for find(:all/:first/:last) #11413 [nkallen, thechrisoshow] 4 3 5 * Merge the has_finder gem, renamed as 'named_scope'. #11404 [nkallen] 4 6 5 7 class Article < ActiveRecord::Base 6 has_finder:published, :conditions => {:published => true}7 has_finder:popular, :conditions => ...8 named_scope :published, :conditions => {:published => true} 9 named_scope :popular, :conditions => ... 8 10 end 9 11 trunk/activerecord/lib/active_record/base.rb
r9082 r9085 512 512 end 513 513 end 514 514 515 # This is an alias for find(:first). You can pass in all the same arguments to this method as you can 516 # to find(:first) 517 def first(*args) 518 find(:first, *args) 519 end 520 521 # This is an alias for find(:last). You can pass in all the same arguments to this method as you can 522 # to find(:last) 523 def last(*args) 524 find(:last, *args) 525 end 526 515 527 # 516 528 # Executes a custom sql query against your database and returns all the results. The results will trunk/activerecord/test/cases/base_test.rb
r9084 r9085 1626 1626 end 1627 1627 1628 def test_last 1629 assert_equal Developer.find(:first, :order => 'id desc'), Developer.last 1630 end 1631 1628 1632 def test_find_ordered_last 1629 1633 last = Developer.find :last, :order => 'developers.salary ASC' trunk/activerecord/test/cases/finder_test.rb
r9084 r9085 143 143 first = Topic.find(:first, :conditions => "title = 'The First Topic!'") 144 144 assert_nil(first) 145 end 146 147 def test_first 148 assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title 149 end 150 151 def test_first_failing 152 assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'") 145 153 end 146 154