Flowdock
method

construct_count_options_from_legacy_args

Importance_0
v1.2.0 - Show latest stable - 0 notes - Class: ActiveRecord::Calculations::ClassMethods
construct_count_options_from_legacy_args(*args) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/calculations.rb, line 128
        def construct_count_options_from_legacy_args(*args)
          options     = {}
          column_name = :all

          # We need to handle
          #   count()
          #   count(options={})
          #   count(column_name=:all, options={})
          #   count(conditions=nil, joins=nil)      # deprecated
          if args.size > 2
            raise ArgumentError, "Unexpected parameters passed to count(options={}): #{args.inspect}"
          elsif args.size > 0
            if args[0].is_a?(Hash)
              options = args[0]
            elsif args[1].is_a?(Hash)
              column_name, options = args
            else
              # Deprecated count(conditions, joins=nil)
              ActiveSupport::Deprecation.warn(
                "You called count(#{args[0].inspect}, #{args[1].inspect}), which is a deprecated API call. " +
                "Instead you should use count(column_name, options). Passing the conditions and joins as " +
                "string parameters will be removed in Rails 2.0.", caller(2)
              )
              options.merge!(:conditions => args[0])
              options.merge!(:joins      => args[1]) if args[1]
            end
          end

          [column_name, options]
        end
Register or log in to add new notes.