instance method alias_attribute

Ruby on Rails 3.1.12

Since v3.0.20

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

alias_attribute(new_name, old_name)

No documentation comment.

Parameters

new_name req
old_name req
Source
# File activemodel/lib/active_model/attribute_methods.rb, line 238
      def alias_attribute(new_name, old_name)
        attribute_method_matchers.each do |matcher|
          matcher_new = matcher.method_name(new_name).to_s
          matcher_old = matcher.method_name(old_name).to_s

          if matcher_new =~ COMPILABLE_REGEXP && matcher_old =~ COMPILABLE_REGEXP
            module_eval <<-RUBY, __FILE__, __LINE__ + 1
              def #{matcher_new}(*args)
                send(:#{matcher_old}, *args)
              end
            RUBY
          else
            define_method(matcher_new) do |*args|
              send(matcher_old, *args)
            end
          end
        end
      end

Defined in activemodel/lib/active_model/attribute_methods.rb line 238 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::AttributeMethods::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close