How can I stop the password field being pre-populated on edit?

tsdbrown picture tsdbrown · Oct 14, 2009 · Viewed 8k times · Source

I have this problem all the time in my rails apps and I still need the correct solution. Whenever a user edits their own record the password field is being populated. I suspect its Firefox as setting @user.password = nil in the edit action doesn't help.

The problem is the password confirmation isn't populated so validation fails due to a miss-match.

I've tried the following:

<%= f.label :password %>
<%= f.password_field :password, :value => "", :autofill => false, :class => 'max' %>

But that doesn't do it. I've also tried :autofill => 'off' which doesn't work either.

Does anybody have any suggestions? Thanks.

Answer

Eddy picture Eddy · Oct 14, 2009

Set autocomplete="off" in the form and the input tags

<form name="blah" autocomplete="off">
<input type="password" autocomplete="off">
</form>