Rails 8 authentication: autocomplete username for email_address field

Any idea why the sessions/new.html.erb users autocomplete: “username” for the email field? I’m trying to add a separate username field and it’s behaving strangely. Can I change it to autocomplete: “email_address” ?

Thanks!

<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: “username”, placeholder: “Enter your email address”, value: params[:email_address] %>

You can change it to “email”

1 Like

If you are using email field and a separate username field, you can use “autocomplete: email” and “autocomplete: username” on those fields respectively.

autocomplete: “email_address” is not valid as the autocomplete token should be from a predefined list. Please check more details here

1 Like

yes only 13 on the predefined list, nothing else

1 Like

here you will see all the other autocomplete tokens

1 Like

Yeah, just use ‘email’ like they said. Tbh Rails probably went with ‘username’ as a safe catch-all since most password managers will autocomplete your email either way, but being explicit with ‘email’ is cleaner. Fair warning though — browser autocomplete behavior can be weird across different managers, so test it after you swap it over.