· 1 min read

Aliasing Attributes in Ruby on Rails

Alias an attribute with alias_attribute method. The first argument is the name for the new attribute, while the second argument is to identify the attribute that is already defined.

class User < ActiveRecord::Base
  alias_attribute :username, :login
end

Comments

Leave a comment