I can not seem to make finders work with aliases. My goal is to map
some fugly field names to nice field names and have the finders work
with the nice field names.
An example.
class Users < ActiveRecord::Base
alias :password :UserPWD
end
This doesn’t seem to work because obviously the object doesn’t have a
method called UserPWD.
What is the best way (short of a view) to create field name mappings?
Is it possible to make it so that my finders also work with the new
names so I can type Users.find_by_password rather then
Users.find_by_UserPWD
I can not seem to make finders work with aliases. My goal is to map
some fugly field names to nice field names and have the finders work
with the nice field names.
An example.
class Users < ActiveRecord::Base
alias :password :UserPWD
end
def password
UserPWD
end
This doesn’t seem to work because obviously the object doesn’t have a
method called UserPWD.
What is the best way (short of a view) to create field name mappings?
Is it possible to make it so that my finders also work with the new
names so I can type Users.find_by_password rather then
Model names are typically singular.
Users.find_by_UserPWD
def self.find_by_password( p )
self.find_by_UserPWD p
end