Skip to content
This repository
Browse code

Remove order_values argument now that default_scope is simplified

In 94924dc the internal default_scope
implementation has changed making it simpler to follow, meaning that the
old usage of with_default_scope has been removed.

With that, order_values was the same argument for both calls to
find_first_with_limit, so remove it and use the existent attribute
for the sake of clarity/simplification.
  • Loading branch information...
commit 5e6de3942ffbc667d1f43860a0c80dd8031a0c60 1 parent 94924dc
Carlos Antonio da Silva carlosantoniodasilva authored
10 activerecord/lib/active_record/relation/finder_methods.rb
@@ -32,7 +32,7 @@ module FinderMethods
32 32 # end
33 33 #
34 34 # ==== Variations of +find+
35   - #
  35 + #
36 36 # Person.where(name: 'Spartacus', rating: 4)
37 37 # # returns a chainable list (which can be empty).
38 38 #
@@ -49,7 +49,7 @@ module FinderMethods
49 49 #
50 50 # Person.where(name: 'Spartacus', rating: 4).exists?(conditions = :none)
51 51 # # returns a boolean indicating if any record with the given conditions exist.
52   - #
  52 + #
53 53 # Person.where(name: 'Spartacus', rating: 4).select("field1, field2, field3")
54 54 # # returns a chainable list of instances with only the mentioned fields.
55 55 #
@@ -124,7 +124,7 @@ def take!
124 124 #
125 125 def first(limit = nil)
126 126 if limit
127   - find_first_with_limit(order_values, limit)
  127 + find_first_with_limit(limit)
128 128 else
129 129 find_first
130 130 end
@@ -353,11 +353,11 @@ def find_first
353 353 if loaded?
354 354 @records.first
355 355 else
356   - @first ||= find_first_with_limit(order_values, 1).first
  356 + @first ||= find_first_with_limit(1).first
357 357 end
358 358 end
359 359
360   - def find_first_with_limit(order_values, limit)
  360 + def find_first_with_limit(limit)
361 361 if order_values.empty? && primary_key
362 362 order(arel_table[primary_key].asc).limit(limit).to_a
363 363 else

0 comments on commit 5e6de39

Please sign in to comment.
Something went wrong with that request. Please try again.