{"action":"created","issue":{"url":"https://api.github.com/repos/plataformatec/devise/issues/3517","labels_url":"https://api.github.com/repos/plataformatec/devise/issues/3517/labels{/name}","comments_url":"https://api.github.com/repos/plataformatec/devise/issues/3517/comments","events_url":"https://api.github.com/repos/plataformatec/devise/issues/3517/events","html_url":"https://github.com/plataformatec/devise/issues/3517","id":62418941,"number":3517,"title":"Email case sensitivity and reconfirmation mail","user":{"login":"olegykz","id":688325,"avatar_url":"https://avatars.githubusercontent.com/u/688325?v=3","gravatar_id":"","url":"https://api.github.com/users/olegykz","html_url":"https://github.com/olegykz","followers_url":"https://api.github.com/users/olegykz/followers","following_url":"https://api.github.com/users/olegykz/following{/other_user}","gists_url":"https://api.github.com/users/olegykz/gists{/gist_id}","starred_url":"https://api.github.com/users/olegykz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegykz/subscriptions","organizations_url":"https://api.github.com/users/olegykz/orgs","repos_url":"https://api.github.com/users/olegykz/repos","events_url":"https://api.github.com/users/olegykz/events{/privacy}","received_events_url":"https://api.github.com/users/olegykz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-17T14:52:39Z","updated_at":"2015-03-17T17:50:48Z","closed_at":null,"body":"If the user change it's email from \"test@domain.com\" to \"tEsT@domain.com\" the reconfirmation mail will be sended.\r\n\r\nThe problem is that even if we have setting \"config.case_insensitive_keys = [ :email ]\" - email attribute will be marked as changed because **downcase!** was triggered for our insensitive key.\r\n\r\nWe need to check - is the **email** attribute was really changed?\r\n```ruby\r\ndef postpone_email_change?\r\n  postpone = self.class.reconfirmable && email_changed? && \r\n    (email_change.to_a.uniq.size == 2) && !@bypass_confirmation_postpone && self.email.present?\r\n  @bypass_confirmation_postpone = false\r\n  postpone\r\n\r\nend\r\n```\r\n\r\nRails (3.2.19)\r\nDevise (2.1.0)"},"comment":{"url":"https://api.github.com/repos/plataformatec/devise/issues/comments/82496466","html_url":"https://github.com/plataformatec/devise/issues/3517#issuecomment-82496466","issue_url":"https://api.github.com/repos/plataformatec/devise/issues/3517","id":82496466,"user":{"login":"olegykz","id":688325,"avatar_url":"https://avatars.githubusercontent.com/u/688325?v=3","gravatar_id":"","url":"https://api.github.com/users/olegykz","html_url":"https://github.com/olegykz","followers_url":"https://api.github.com/users/olegykz/followers","following_url":"https://api.github.com/users/olegykz/following{/other_user}","gists_url":"https://api.github.com/users/olegykz/gists{/gist_id}","starred_url":"https://api.github.com/users/olegykz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegykz/subscriptions","organizations_url":"https://api.github.com/users/olegykz/orgs","repos_url":"https://api.github.com/users/olegykz/repos","events_url":"https://api.github.com/users/olegykz/events{/privacy}","received_events_url":"https://api.github.com/users/olegykz/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T17:50:48Z","updated_at":"2015-03-17T17:50:48Z","body":"If I set email key as insensitive I expect that system won't send any reconfirmation emails.\r\nActually, this is not bug of Rails or Ruby(**downcase!** - method of ruby std library, http://ruby-doc.org/core-2.1.0/String.html#method-i-downcase-21).\r\n\r\nAnd the simple solution is avoiding **downcase!** method which marks attribute as changed.\r\n\r\n**authenticatable.rb**:\r\n```ruby\r\ndef downcase_keys\r\n  self.class.case_insensitive_keys.each { |k| self[k] = self[k].try(:downcase) }\r\nend\r\n```\r\n\r\n\r\n\r\n"}}