设计:客户端验证gem工作,但文本没有出现

时间:2012-12-14 11:59:20

标签: ruby-on-rails devise

我有一个使用Devise和ClientSideValidations宝石的应用程序。

在下面的表格中,我的客户端验证与设计一起使用。我认为这是有效的,因为它现在不可能实际提交表格。我的问题是文本字段标签旁边没有任何文本,例如“不能为空”。知道我做错了吗?

%h3 Sign up
%br
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true) do |f|
  %h4
    = devise_error_messages!
  %div
    = f.label :name
    = f.text_field :name, :validate => true
  %div
    = f.label :email
    = f.email_field :email, :validate => { :presence => :true }

  %div
    = f.label :password
    = f.password_field :password, :validate => { :presence => :true, :length => true }
  %div
    = f.label :password_confirmation
    = f.password_field :password_confirmation,  :validate => { :presence => true }
  %div
    = f.submit "Sign up", id: 'button'
= render "devise/shared/links"

当我查看来源时,会出现js。

<script>//<![CDATA[
if(window.ClientSideValidations==undefined)window.ClientSideValidations={};if(window.ClientSideValidations.forms==undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['new_user'] = {"type":"ActionView::Helpers::FormBuilder","input_tag":"<div class=\"field_with_errors\"><span id=\"input_tag\" /></div>","label_tag":"<div class=\"field_with_errors\"><label id=\"label_tag\" /></div>","validators":{"user[name]":{"presence":[{"message":"can't be blank"}]},"user[email]":{"presence":[{"message":"can't be blank"}]},"user[password]":{"presence":[{"message":"can't be blank"}],"length":[{"messages":{"minimum":"is too short (minimum is 6 characters)","maximum":"is too long (maximum is 128 characters)"},"allow_blank":true,"minimum":6,"maximum":128}]}}};
//]]></script>

所以我知道它并且我相信它正在完成它的工作,但出于某种原因,我只是没有看到当我将一个字段留空时我会期望的错误信息。

0 个答案:

没有答案