bcardarella/client_side_validations — Issue #206: Rails 3.1.1 & custom validations problem + solution.
Author: konung
Created: 2011-10-26 00:48:13+00:00
State: open

Hi , Brian.

This is mostly a request to update wiki as far as the custom validaitons go.

Here is a problem I ran into when upgrading to rails 3.1.1

I had a bunch of custom validations in RAILS_ROOT/config/initializers/custom_validations/... after the upgrade non of them worked anymore. As a matter of fact I couldn't even start up the app. Can't find any info on this, but as far as I can figure this, subfolders in initializers folder are not autoloaded anymore ( it worked fine in 3.1.0)

So I moved my custom validations to RAILS_ROOT/lib/custom_validations/... and added this to application.rb:

config.autoload_paths += %W(#{config.root}/lib #{config.root}/lib/custom_validations )

This is also better for development - cause it will reload your validations if you change them . If they are sitting in initializers forlder, you have to restart app every time you make a change.

Hopefully this will help someone, as it took me an hour to trace this ( I added a couple of new custom validators as I upgraded to 3.1.1 and I thought my new validators are causing app to fail)

Nick