method
alias_attribute
v5.1.7 -
Show latest stable
- Class:
Module
alias_attribute(new_name, old_name)public
Allows you to make aliases for attributes, which includes getter, setter, and a predicate.
class Content < ActiveRecord::Base # has a title attribute end class Email < Content alias_attribute :subject, :title end e = Email.find(1) e.title # => "Superstars" e.subject # => "Superstars" e.subject? # => true e.subject = "Megastars" e.title # => "Megastars"
1Note
Deprecated - replacement method
The description rightly lists this as deprecated, but using it will still work atm, as it seems to have moved to ActiveSupport::CoreExtensions::Module instead.
So your code should still work.