In (at least) Devise 1.0.7, the controllers accept email addresses as-
is (no upper- or lowercase conversion).
This will hose users who don't enter their email address consistently.
A user might register as J...@Example.Com then try to log in as
j...@example.com. It's a support headache waiting to happen.
I think that the Devise team wants to fix this in the controllers
(Internet email addresses are not case-sensitive, but Devise is).
Until that happens, the following gets the job done. You'll need
jQuery for it to work.
1. Add this to app/helpers/application_helper.rb
----------------------------------------
# Convert the email address to lowercase when submitting the form.
This avoids support issues later
# when someone enters their email address in a difference case.
#
# Convert the email address to lowercase on document-ready and field
blur as a cosmetic-only improvement.
def devise_email_text_field(form)
form.text_field(:email, :id => 'devise-email-text-field') + "\n" +
(<<EOF).html_safe
<script type='text/javascript'>
//<![CDATA[
jQuery(document).ready(function() {
var field = jQuery('#devise-email-text-field');
field.val(field.val().toLowerCase());
field.blur(function() {
field.val(field.val().toLowerCase());
});
var form = field.closest('form');
form.submit(function() {
field.val(field.val().toLowerCase());
});
});
//]]>
</script>
EOF
end
----------------------------------------
2. In the Devise views (you do have your own views, don't you?),
replace this:
----------------------------------------
= f.text_field :email
----------------------------------------
with this:
----------------------------------------
= devise_email_text_field(f)
----------------------------------------
Crude, but effective :-)
-- Adam