title: Rails 3: alias_attribute and Unkown column error
body: <p>I am using Devise for authentication, so I've aliased a few columns in my legacy database to accommodate it as follows:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  
    set_table_name 'my_legacy_user_table'
    set_primary_key 'UserId'
    alias_attribute :id, :UserId
    alias_attribute :username, :LoginId
    alias_attribute :encrypted_password, :PasswordSHA1Hash
    alias_attribute :first_name, :Name
    alias_attribute :last_name, :Surname
  
    devise :database_authenticatable, :authentication_keys =&gt; [:username]
  
    attr_accessible :username, :password, :password_confirmation
  
    def password_salt=(password_salt)
    end
  
    def password_salt
    end
  
    def password_digest(password)
      self.class.encryptor_class.digest(password)
    end
  
  end
  </code></pre>
  
  <p>When I post to my /users/sign_in form, I get the following exception:</p>
  
  <pre><code>Mysql2::Error: Unknown column 'my_legacy_user_table.username' in 'where clause': SELECT `kms_User`.* FROM `my_legacy_user_table` WHERE (`my_legacy_user_table`.`username` = 'mrichman') LIMIT 1
  </code></pre>
  
  <p>I suppose I was under the assumption that <code>alias_attribute</code> would instruct ActiveRecord to use the real column name (UserId) and not the alias (username). What am I doing wrong?</p>