Rails 3自定义验证器应存储在哪里? [英] Where should Rails 3 custom validators be stored?

查看:83
本文介绍了Rails 3自定义验证器应存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到文档/网站显示自定义验证器应该放在 / lib / lib / validators 项目目录。我发现(通过阅读另一篇文章的答案)它们似乎只在 config / initializers 中起作用。是否有人知道或有一个指向自定义验证器应该住在哪里的官方文档的指针?

I've seen docs/websites show that custom validators should go in a /lib or /lib/validators directory of a project. I've found (by reading an answer to another post) that they only seem to work in config/initializers. Does anyone know, or have a pointer to official documentation that shows where custom validators should live?

推荐答案

如果放置自定义验证器在 app / validators 中,它们将自动加载而无需更改您的 config / application.rb 文件。

If you place your custom validators in app/validators they will be automatically loaded without needing to alter your config/application.rb file.

这篇关于Rails 3自定义验证器应存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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