# File lib/action_view/helpers/form_helper.rb, line 296
      def form_for(record_or_name_or_array, *args, &proc)
        raise ArgumentError, "Missing block" unless block_given?

        options = args.extract_options!

        case record_or_name_or_array
        when String, Symbol
          ActiveSupport::Deprecation.warn("Using form_for(:name, @resource) is deprecated. Please use form_for(@resource, :as => :name) instead.", caller) unless args.empty?
          object_name = record_or_name_or_array
        when Array
          object = record_or_name_or_array.last
          object_name = options[:as] || ActiveModel::Naming.singular(object)
          apply_form_for_options!(record_or_name_or_array, options)
          args.unshift object
        else
          object = record_or_name_or_array
          object_name = options[:as] || ActiveModel::Naming.singular(object)
          apply_form_for_options!([object], options)
          args.unshift object
        end

        (options[:html] ||= {})[:remote] = true if options.delete(:remote)

        output = form_tag(options.delete(:url) || {}, options.delete(:html) || {})
        output << fields_for(object_name, *(args << options), &proc)
        output.safe_concat('</form>')
      end