# File lib/active_record/base.rb, line 378
      def find(*args)
        options = extract_options_from_args!(args)

        # Inherit :readonly from finder scope if set.  Otherwise,
        # if :joins is not blank then :readonly defaults to true.
        unless options.has_key?(:readonly)
          if scoped?(:find, :readonly)
            options[:readonly] = scope(:find, :readonly)
          elsif !options[:joins].blank?
            options[:readonly] = true
          end
        end

        case args.first
          when :first
            find(:all, options.merge(options[:include] ? { } : { :limit => 1 })).first
          when :all
            records = options[:include] ? find_with_associations(options) : find_by_sql(construct_finder_sql(options))
            records.each { |record| record.readonly! } if options[:readonly]
            records
          else
            return args.first if args.first.kind_of?(Array) && args.first.empty?
            expects_array = args.first.kind_of?(Array)
            
            conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]

            ids = args.flatten.compact.uniq
            case ids.size
              when 0
                raise RecordNotFound, "Couldn't find #{name} without an ID#{conditions}"
              when 1
                if result = find(:first, options.merge({ :conditions => "#{table_name}.#{primary_key} = #{sanitize(ids.first)}#{conditions}" }))
                  return expects_array ? [ result ] : result
                else
                  raise RecordNotFound, "Couldn't find #{name} with ID=#{ids.first}#{conditions}"
                end
              else
                # Find multiple ids
                ids_list = ids.map { |id| sanitize(id) }.join(',')
                result   = find(:all, options.merge({ :conditions => "#{table_name}.#{primary_key} IN (#{ids_list})#{conditions}"}))
                if result.size == ids.size
                  return result
                else
                  raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
                end
            end
        end
      end