diff options
| author | Marcelo Silveira <marcelo@mhfs.com.br> | 2012-04-27 18:22:11 -0300 | 
|---|---|---|
| committer | Marcelo Silveira <marcelo@mhfs.com.br> | 2012-05-02 21:25:41 -0300 | 
| commit | 2bf65caf565c5923684953557594fc287c80c6ca (patch) | |
| tree | 9e060a9491606eebee468ff8573e42f925280678 | |
| parent | 66b9e4c857b5987a52f0442ae382ee18dc3dd30a (diff) | |
| download | rails-2bf65caf565c5923684953557594fc287c80c6ca.tar.gz rails-2bf65caf565c5923684953557594fc287c80c6ca.tar.bz2 rails-2bf65caf565c5923684953557594fc287c80c6ca.zip | |
Use Array#first instead of Array#[0]
| -rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 7af69d3483..d13bed95ce 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -350,9 +350,9 @@ module ActiveRecord      def find_take        if loaded? -        @records.take(1)[0] +        @records.take(1).first        else -        @take ||= limit(1).to_a[0] +        @take ||= limit(1).to_a.first        end      end @@ -362,9 +362,9 @@ module ActiveRecord        else          @first ||=            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 -            limit(1).to_a[0] +            limit(1).to_a.first            end        end      end @@ -377,7 +377,7 @@ module ActiveRecord            if offset_value || limit_value              to_a.last            else -            reverse_order.limit(1).to_a[0] +            reverse_order.limit(1).to_a.first            end        end      end | 
