我正在使用 Ruby on Rails 制作我的登录表单,在尝试登录或创建新帐户时,我收到此客户端错误,阻止我发布表单。
这是我用来生成表单视图的 Ruby 代码。
#account-form
h2 Create your free account!
p Signing up is completely free and you can use all of our features.
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-group
= f.label :email
= f.input_field :email, class: 'form-control'
.form-group
= f.label :password
= f.input_field :password, required: true, class: 'form-control'
.form-group
= f.label :password_confirmation
= f.input_field :password_confirmation, require: true, class: 'form-control'
button.btn.btn-default type='submit' Sign up
= render 'devise/shared/links'
这将生成以下 HTML(用于输入):
<input class="string email optional form-control"
id="user_email"
maxlength="255"
name="user[email]"
pattern="\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z"
size="255"
type="text" value="">
为什么我的有效电子邮件会导致此验证触发?有什么建议么?