Skip to content

Commit

Permalink
Use Array#first instead of Array#[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
mhfs committed May 3, 2012
1 parent 66b9e4c commit 2bf65ca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/relation/finder_methods.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ def find_some(ids)


def find_take def find_take
if loaded? if loaded?
@records.take(1)[0] @records.take(1).first
else else
@take ||= limit(1).to_a[0] @take ||= limit(1).to_a.first
end end
end end


Expand All @@ -362,9 +362,9 @@ def find_first
else else
@first ||= @first ||=
if order_values.empty? && primary_key if order_values.empty? && primary_key
order("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(1).to_a[0] order("#{quoted_table_name}.#{quoted_primary_key} ASC").limit(1).to_a.first
else else
limit(1).to_a[0] limit(1).to_a.first
end end
end end
end end
Expand All @@ -377,7 +377,7 @@ def find_last
if offset_value || limit_value if offset_value || limit_value
to_a.last to_a.last
else else
reverse_order.limit(1).to_a[0] reverse_order.limit(1).to_a.first
end end
end end
end end
Expand Down

0 comments on commit 2bf65ca

Please sign in to comment.