title: Devise - sign in by email OR username
body: <p>I've done all of the this tutorial: <a href="https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address" rel="nofollow">Devise wiki</a></p>
  
  <p>But when I try to log in I get error in the browser:</p>
  
  <pre><code>SQLite3::SQLException: no such column: users.login: SELECT "users".* FROM "users" WHERE "users"."login" = 'jan12345' ORDER BY "users"."id" ASC LIMIT 1
  </code></pre>
  
  <p>Where could be a problem? How to debug this?</p>
  
  <p>I don't have <code>login</code> field on the <code>users</code> table but I have <code>username</code> field.</p>
  
  <p>My model file:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    attr_accessor :login
    protect_from_forgery with: :exception
  
    before_action :configure_permitted_parameters, if: :devise_controller?
  
    protected
  
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :expiration_date) }
      devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
    end
  end
  </code></pre>