Where should Rails 3 custom validators be stored?

Daniel D picture Daniel D · Mar 10, 2011 · Viewed 18.6k times · Source

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?

Answer

gbc picture gbc · Jul 7, 2011

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