title: NoMethodError - undefined method `email' for #<ActionDispatch::
body: <p>Devise 3.5.2, Rails 4.2.3</p>
  
  <p>While logging in, I'm trying to pass a hidden role_id along with the email/password combination. I am allowing the same email to register again, on a different subdomain, which causes a different role_id to be passed. The email+role_id is the unique index for the user.</p>
  
  <p>I can create a user, but cannot log in. When I submit the log in form, I am faced with the following error:</p>
  
  <p><code>undefined method 'email' for #&lt;ActionDispatch::Request:0x007fa21628bda0&gt;</code></p>
  
  <h1>EDIT:</h1>
  
  <p>If anyone can explain the process of changing the email uniqueness validation to email+role_id (not either/or, but and), that's all I need to accomplish. Following that process properly may avoid this error.</p>
  
  <h2>Debugging info:</h2>
  
  <p>The POST parameters are as follows:</p>
  
  <pre><code>{"utf8"=&gt;"✓",
   "authenticity_token"=&gt;"[FILTERED]",
   "member"=&gt;{"role_id"=&gt;"1",
   "email"=&gt;"some.user@email.com",
   "password"=&gt;"[FILTERED]",
   "remember_me"=&gt;"0"},
   "commit"=&gt;"Log in"}
  </code></pre>
  
  <p>Here is my Member model:</p>
  
  <pre><code>class Member &lt; ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, :registerable,
           :recoverable, :rememberable, :trackable, :validatable,
           :confirmable, :lockable, :timeoutable, :omniauthable
  
    belongs_to :role
  
    def self.find_for_authentication(warden_conditions)
      where(:email =&gt; warden_conditions[:email], :role_id =&gt; warden_conditions[:role_id]).first
    end
  end
  </code></pre>
  
  <p>In <em>config/initializers/devise.rb</em>, the following is set:</p>
  
  <p><code>config.authentication_keys = [:email, :role_id]</code></p>
  
  <p><code>config.request_keys = [:email, :role_id]</code></p>
  
  <p>My views/devise/sessions/new.html.erb includes:</p>
  
  <p><code>&lt;%= f.hidden_field :role_id, :value =&gt; Role.find_by_name(current_subdomain).id %&gt;</code></p>
  
  <p>I adjusted <em>vendor/bundle/ruby/1.9.1/gems/devise-3.5.2/lib/devise/models/validatable.rb</em> by changing this line:</p>
  
  <pre><code>validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>validates_uniqueness_of :email, :scope =&gt; :role_id, allow_blank: true, if: :email_changed? #using subdomains for validation
  </code></pre>
  
  <p>The relevant database migrations for the member are found here:</p>
  
  <h3>...devise_create_members.rb</h3>
  
  <pre><code>class DeviseCreateMembers &lt; ActiveRecord::Migration
    def change
      create_table(:members) do |t|
        ## Database authenticatable
        t.string :email,              null: false, default: ""
        t.string :encrypted_password, null: false, default: ""
  
        ## Recoverable
        t.string   :reset_password_token
        t.datetime :reset_password_sent_at
  
        ## Rememberable
        t.datetime :remember_created_at
  
        ## Trackable
        t.integer  :sign_in_count, default: 0, null: false
        t.datetime :current_sign_in_at
        t.datetime :last_sign_in_at
        t.string   :current_sign_in_ip
        t.string   :last_sign_in_ip
  
        ## Confirmable
        t.string   :confirmation_token
        t.datetime :confirmed_at
        t.datetime :confirmation_sent_at
        t.string   :unconfirmed_email # Only if using reconfirmable
  
        ## Lockable
        t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
        t.string   :unlock_token # Only if unlock strategy is :email or :both
        t.datetime :locked_at
  
  
        t.timestamps null: false
      end
  
      add_index :members, :email,                unique: true
      add_index :members, :reset_password_token, unique: true
      add_index :members, :confirmation_token,   unique: true
      add_index :members, :unlock_token,         unique: true
    end
  </code></pre>
  
  <h3>...add_columns_to_member.rb</h3>
  
  <pre><code>class AddColumnsToMember &lt; ActiveRecord::Migration
    def change
      add_reference :members, :contact, index: true
      add_reference :members, :role, index: true
      add_reference :members, :ownership, index: true
      add_column :members, :account_status, :string
    end
  end
  </code></pre>
  
  <h3>...reindex_members_email_and_role.rb</h3>
  
  <pre><code>class ReindexMembersEmailAndRole &lt; ActiveRecord::Migration
    def change
      add_index :members, [:email, :role_id], :unique =&gt; true
    end
  end
  </code></pre>
  
  <p>The last item on the trace is:</p>
  
  <p><em>vendor/bundle/ruby/1.9.1/gems/devise-3.5.2/lib/devise/strategies/authenticatable.rb:152:in `block in request_values'</em></p>
  
  <pre><code>    keys = request_keys.respond_to?(:keys) ? request_keys.keys : request_keys
      values = keys.map { |k| self.request.send(k) } &lt;--ERROR THIS LINE
      Hash[keys.zip(values)]
    end
  </code></pre>
  
  <h3>What am I missing?</h3>