{"action":"opened","issue":{"url":"https://api.github.com/repos/plataformatec/devise/issues/3524","labels_url":"https://api.github.com/repos/plataformatec/devise/issues/3524/labels{/name}","comments_url":"https://api.github.com/repos/plataformatec/devise/issues/3524/comments","events_url":"https://api.github.com/repos/plataformatec/devise/issues/3524/events","html_url":"https://github.com/plataformatec/devise/issues/3524","id":62672013,"number":3524,"title":"Authenticate with attributes from associated model (User belongs to Client)","user":{"login":"robotex82","id":655932,"avatar_url":"https://avatars.githubusercontent.com/u/655932?v=3","gravatar_id":"","url":"https://api.github.com/users/robotex82","html_url":"https://github.com/robotex82","followers_url":"https://api.github.com/users/robotex82/followers","following_url":"https://api.github.com/users/robotex82/following{/other_user}","gists_url":"https://api.github.com/users/robotex82/gists{/gist_id}","starred_url":"https://api.github.com/users/robotex82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robotex82/subscriptions","organizations_url":"https://api.github.com/users/robotex82/orgs","repos_url":"https://api.github.com/users/robotex82/repos","events_url":"https://api.github.com/users/robotex82/events{/privacy}","received_events_url":"https://api.github.com/users/robotex82/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-18T11:48:14Z","updated_at":"2015-03-18T11:48:14Z","closed_at":null,"body":"I have following models:\r\n\r\n    # app/models/user.rb\r\n    User < ActiveRecord::Base\r\n      belongs_to :client\r\n    end \r\n\r\n    # app/models/client.rb\r\n    Client < ActiveRecord::Base\r\n      has_many :users\r\n      validates :identifier, presence: true\r\n    end\r\n\r\nI've overridden the session controller to use a different view with the suiting form inputs:\r\n\r\n    # new.html.erb\r\n    ...\r\n    <div class=\"form-inputs\">\r\n      <%= f.fields_for :client do |c| %>\r\n        <%= c.input :identifier, :required => true, :autofocus => true %>\r\n      <% end %>\r\n      <%= f.input :email, :required => false %>\r\n      <%= f.input :password, :required => false %>\r\n      <%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>\r\n    </div>\r\n    ...\r\n\r\nWhat would the correct way to get the user to authenticate with a client identifier in addition to the email address?\r\n\r\nThanks in advance!\r\n\r\nBest regards\r\nRoberto"}}