method
alias_attribute_method_definition
v8.0.0 -
Show latest stable
- Class:
ActiveRecord::AttributeMethods::ClassMethods
alias_attribute_method_definition(code_generator, pattern, new_name, old_name)public
No documentation available.
# File activerecord/lib/active_record/attribute_methods.rb, line 87
def alias_attribute_method_definition(code_generator, pattern, new_name, old_name) # :nodoc:
old_name = old_name.to_s
if !abstract_class? && !has_attribute?(old_name)
raise ArgumentError, "#{self.name} model aliases `#{old_name}`, but `#{old_name}` is not an attribute. " "Use `alias_method :#{new_name}, :#{old_name}` or define the method manually."
else
define_attribute_method_pattern(pattern, old_name, owner: code_generator, as: new_name, override: true)
end
end