使用ActiveRecord模型验证器进行Javascript验证 [英] Javascript validation using activerecord models validators

查看:87
本文介绍了使用ActiveRecord模型验证器进行Javascript验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个activerecord模型和一组验证器,但我还必须提供前端验证.

I have an activerecord model and set of validators to it, But I also have to provide front end validation.

例如在jquery验证插件中,有没有宝石或聪明的方法来使用activerecord验证器,而不是手工编写?

Is there a gem or a smart way to use activerecord validators, for instance in jquery validation plugin, instead of writing it by hand?

谢谢

推荐答案

无需重复这些费用. 周围有一些宝石/插件在客户端重复了模型的验证. 是的,您仍然必须进行一些客户端自定义,但这应该非常容易.

No need to duplicate the costs. There are some gems/plugins around that duplicate the Model's validations in the client side. yes, you'll have to do some client-side customizations still, but it should be very easy.

这是此类插件的示例: http://github.com/grimen/validatious-on -rails

here's an example of such plugin: http://github.com/grimen/validatious-on-rails

这篇关于使用ActiveRecord模型验证器进行Javascript验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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