Where should Rails 3 custom validators be stored?

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


lib/validators seems by far the cleanest. However you may need to load them in before your models, so probably from an initializer.


If you add this to your /config/application.rb file:

config.autoload_paths += %W["#{config.root}/lib/validators/"]

Then Rails will automatically load your validators on start up (just like /config/initializers/), but you keep the clean structure of having your validators in one nice, well named spot.