instance method define_attribute_methods

Ruby on Rails 3.2.22.5

Since v2.2.3 Last seen in v3.2.22.5

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5

Signature

define_attribute_methods()

Generates all the attribute related methods for columns in the database accessors, mutators and query methods.

Source
# File activerecord/lib/active_record/attribute_methods.rb, line 38
      def define_attribute_methods
        unless defined?(@attribute_methods_mutex)
          msg = "It looks like something (probably a gem/plugin) is overriding the " \
                "ActiveRecord::Base.inherited method. It is important that this hook executes so " \
                "that your models are set up correctly. A workaround has been added to stop this " \
                "causing an error in 3.2, but future versions will simply not work if the hook is " \
                "overridden. If you are using Kaminari, please upgrade as it is known to have had " \
                "this problem.\n\n"
          msg << "The following may help track down the problem:"

          meth = method(:inherited)
          if meth.respond_to?(:source_location)
            msg << " #{meth.source_location.inspect}"
          else
            msg << " #{meth.inspect}"
          end
          msg << "\n\n"

          ActiveSupport::Deprecation.warn(msg)

          @attribute_methods_mutex = Mutex.new
        end

        # Use a mutex; we don't want two thread simaltaneously trying to define
        # attribute methods.
        @attribute_methods_mutex.synchronize do
          return if attribute_methods_generated?
          superclass.define_attribute_methods unless self == base_class
          super(column_names)
          column_names.each { |name| define_external_attribute_method(name) }
          @attribute_methods_generated = true
        end
      end

Defined in activerecord/lib/active_record/attribute_methods.rb line 38 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::AttributeMethods::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close