客户端验证与Devise

客户端验证与Devise

本文介绍了客户端验证与Devise的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Devise的client_side_validations宝石来验证设计注册表单。



验证工作正常,只有不是Devise生成的表单。 >

我添加了相关的:validate => true,但验证只有在我不按标签上提交时才能工作,就像在其他表单上一样。

 < h2>注册< / h2> 
< hr />

<%= form_for(resource,:validate => true,:as => resource_name,:url => registration_path(resource_name))do | f | %GT;
<%= devise_error_messages! %GT;

< div><%= f.label:username%>
<%= f.text_field:username%>< / div>

< div><%= f.label:email%>
<%= f.email_field:email%>< / div>

< div><%= f.label:password%>
<%= f.password_field:password%>< / div>

< div><%= f.label:password_confirmation%>
<%= f.password_field:password_confirmation%>< / div>

< br />

< div><%= f.submit注册,:class => btn btn-primary btn-large%>< / div>
<%end%>

<%= renderlinks%>


解决方案

Argc,argv!我使用的是Rails 3.2.1,最新发布的gem与3.2不兼容,所以就是噩梦。使用3.2.0.beta.2来解决问题。谢谢!


I am trying to use the client_side_validations gem with Devise to validate devise registrations form.

Validations work fine with everything else just not the Devise generated form.

I added the relevant :validate => true but the validations only work when I hit submit not on tab like they do on every other form.

<h2>Sign up</h2>
<hr />

<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>

  <div><%= f.label :username %>
  <%= f.text_field :username %></div>

  <div><%= f.label :email %>
  <%= f.email_field :email %></div>

  <div><%= f.label :password %>
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %>
  <%= f.password_field :password_confirmation %></div>

  <br />

  <div><%= f.submit "Sign up", :class => "btn btn-primary btn-large" %></div>
<% end %>

<%= render "links" %>
解决方案

Argc, argv! I am using Rails 3.2.1, the latest release of the gem is incompatible with 3.2 hence the nightmare. Using 3.2.0.beta.2 fixes the problems. Thanks!

这篇关于客户端验证与Devise的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:11