activerecord/lib/active_record/associations/collection_association.rb
# Fetches the first/last using SQL if possible, otherwise from the target array.
Fetches the first/last using SQL if possible, otherwise from the target array.
Fetches the first / last using SQL if possible otherwise from the target array .
def first_nth_or_last(type, *args)
          args.shift if args.first.is_a?(Hash) && args.first.empty?
          collection = fetch_first_nth_or_last_using_find?(args) ? scope : load_target
          collection.send(type, *args).tap do |record|
            set_inverse_instance record if record.is_a? ActiveRecord::Base
          end
        end
def first_nth_or_last ( type , * args ) args . shift if args . first . is_a? ( Hash ) && args . first . empty? collection = fetch_first_nth_or_last_using_find? ( args ) ? scope : load_target collection . send ( type , * args ) . tap do | record | set_inverse_instance record if record . is_a? ActiveRecord :: Base end end
Fetches the first/last using SQL if possible, otherwise from the target array.
Fetches the first / last using SQL if possible otherwise from the target array .
type
<not_specific>
args
<not_specific>