Is it possible to use attribute aliases? I got an attribute called
“user_name”, a plugin uses the attribute “login” instead. Can I make
“login” an alias for “user_name”?
Jonas wrote:
Is it possible to use attribute aliases? I got an attribute called
“user_name”, a plugin uses the attribute “login” instead. Can I make
“login” an alias for “user_name”?
def login
self.user_name
end
def login=(login)
self.user_name = login
end
–
Cheers,
- Jacob A.
def login
self.user_name
enddef login=(login)
self.user_name = login
end
I’ve done that. But then stuff like “find_by_login” do not work.
I haven’t heard of a way to get the full palette of AR “magic” functions
aliased, sorry.
Ok. I’ve tried to add the method below to the model, but I still get
method_missing exception.
def find_by_login(value)
find_by_user_name value
end
Jonas wrote:
def login
self.user_name
enddef login=(login)
self.user_name = login
endI’ve done that. But then stuff like “find_by_login” do not work.
I haven’t heard of a way to get the full palette of AR “magic” functions
aliased, sorry.
–
Cheers,
- Jacob A.
Hi Jonas,
I think you want the class method so instead of:
- def find_by_login(value)
you want to say:
- def self.find_by_login value
Also I wouldn’t use any more magic methods like:
- find_by_user_name value
instead I would use:
- find :first, :conditions => [ ‘user_name = ?’, value ]
…but that’s another story…
Regards
Florian
Jonas schrieb: