alias_attribute(new_name, old_name) public

Allows you to make aliases for attributes, which includes getter, setter, and query methods.


class Content < ActiveRecord::Base
  # has a title attribute

class Email < Content
  alias_attribute :subject, :title

e = Email.find(1)
e.title    # => "Superstars"
e.subject  # => "Superstars"
e.subject? # => true
e.subject = "Megastars"
e.title    # => "Megastars"
Show source
Register or log in to add new notes.
March 27, 2009
2 thanks

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.