attribute alias

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

Jonas wrote:

def login
   self.user_name
end

def 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.

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... :slight_smile:

Regards
Florian

Jonas schrieb: