Rails 4客户端验证 [英] Rails 4 client side validation

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

问题描述

自将我的网站升级到Rails 4后,客户端验证gem已停止为我工作。我已经看过各种替代方案,例如jquery-validation-rails和judge,它们涉及编写相当多的javascript,特别是对于一个如此大的网站。在jquery-validation-rails的情况下,重新执行客户端的所有验证规则。考虑到Rails是一个如此流行的框架,令我惊讶的是没有简单的选择。有没有其他任何人都知道的宝石,它会进行验证以及客户端验证宝石?

Since upgrading my site to Rails 4, the client-side-validations gem has stopped working for me. I have had a look at the various alternatives such as jquery-validation-rails and judge, which involve writing quite a bit of javascript, especially for a site so large. And in the case of jquery-validation-rails, re-doing all the validation rules client side. Considering Rails is such a popular framework, it surprises me that there is no 'easy' option. Is there any gem which anyone else is aware of, which does validation as well as the client-side-validation gem?

或者是使用ModelName的最佳选择。验证器方法与一些ajax混合,并通过jquery-validation-rails gem进行验证?

Or is the best alternative to use the ModelName.validators method mixed with some ajax, and do the validation through the jquery-validation-rails gem?

推荐答案

来自Google。

http://rubygems.org/gems/rails4_client_side_validations

https://github.com/ amatsuda / html5_validators

此外,这家伙似乎已经使用4-0-beta分支获得了相同的宝石。

Also this guy seemed to have gotten the same gem you are using to work by using the 4-0-beta branch.

客户端验证和Rails4

如果4-0-beta分支适合您,请考虑帮助维护宝石以保持它的活力。

If the 4-0-beta branch works for you, consider helping to maintain the gem to keep it alive.

在你的Gemfile中使用某个git repo版本:

To use a certain git repo version in your Gemfile:

gem 'client-side-validations', :git => 'https://github.com/bcardarella/client_side_validations/tree/4-0-beta'

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆