On Feb 6, 2008 8:35 PM, Tim Uckun
<timuckun-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> 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
--
Greg Donald
http://destiney.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---