alias_method on a model

Is there a way to alias an automaically created model attribute? I have a
column named start_time, and when I use

alias_method :default_start_time, :start_time

In the model's class definition, I get an "undefined method" error

Thanks!
Daniel

Nope. Attribute access is implemented through method_missing, which
means that the method you're trying to alias just won't exist. You can
still alias things the "long" way:

def default_start_time
  start_time
end

or on one line, if you prefer:

def default_start_time; start_time end

Daniel Higginbotham wrote:

Try alias_attribute.

jeremy

Yeah, it's easy enough to miss: the method_missing defined on line 1090 (activerecord 1.14.4, base.rb) implements the dynamic finders for the class, and the method_missing defined further down on line 1770 implements attribute access for the instances. They're used in different contexts (e.g. Person.find_by_first_name vs person.first_name).

Joe Ruby MUDCRAP-CE wrote:

Thanks everyone!