告知AuthLogic不使用密码确认

4 user-experience ruby-on-rails authlogic password-confirmation

我有这个观点:

new.html.haml

%h1 New account

- form_for @user do |f|
  = f.error_messages
  = render :partial => "form", :object => f
  = f.submit "Create account"
Run Code Online (Sandbox Code Playgroud)

_form.html.haml

= form.label :email
= form.text_field :email
%br/
= form.label :password, form.object.new_record? ? nil : "Change password"
= form.password_field :password
Run Code Online (Sandbox Code Playgroud)

导致这个邪恶的错误消息:

1错误禁止此用户被保存

以下字段存在问题:

  • 密码确认太短(最少4个字符)

我不想要密码确认.密码确认很糟糕,他们阻止超快速注册,这太棒了!任何人都可以解释我如何禁用密码确认?谢谢.

Har*_*tty 12

试试这个:

class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.require_password_confirmation = false
  end
end
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅文档.