Method: ActiveRecord::Base.alias_attribute_with_memory
- Defined in:
- lib/common_lib/active_record/base.rb
.alias_attribute_with_memory(new_name, old_name) ⇒ Object
cattr_accessor here would create a class variable for ActiveRecord::Base What I want is the subclass to have one so just wait until its used the first time and create the class variable them cattr_accessor :aliased_attributes
139 140 141 142 143 144 145 146 |
# File 'lib/common_lib/active_record/base.rb', line 139 def self.alias_attribute_with_memory(new_name, old_name) unless self.class_variable_defined? '@@aliased_attributes' cattr_accessor :aliased_attributes self.aliased_attributes = {}.with_indifferent_access end self.aliased_attributes[new_name] = old_name alias_attribute_without_memory(new_name, old_name) end |