I’ve written a custom validation ah la advanced rails recipes. When i’m
in development everything works great. As soon as I “script/server -e
production”
then my console gets lit up with errors http://www.pastie.org/361177
I played around with what actions cause this, and apparently putting
validates_anything_not_standard :anything
causes an error.
This includes having the validation in my model, or loaded in a
lib/file.rb . This also includes having no validation code, and just
placing “validates_anything_not_standard :anything” call in my model.
I’ve seen a few other posts about similar problems, but nothing
conclusive. Why would this happen only when in the production
environment, and not in development?
On Jan 15, 4:00 am, Richard S. <rails-mailing-l…@andreas- s.net> wrote:
This includes having the validation in my model, or loaded in a
lib/file.rb . This also includes having no validation code, and just
placing “validates_anything_not_standard :anything” call in my model.
I’ve seen a few other posts about similar problems, but nothing
conclusive. Why would this happen only when in the production
environment, and not in development?
When i turned of config.cache_classes in my environments/production.rb
everything worked great. Of course I cant run a deployment like that,
sooo…i moved my " require ‘custom_validations’ " into my model
right above my validation call, to ensure it gets loaded in the right
order. I’m not sure how kosher this is, but it fixed the problem.
When i turned of config.cache_classes in my environments/production.rb
everything worked great. Of course I cant run a deployment like that,
sooo…i moved my " require ‘custom_validations’ " into my model
right above my validation call, to ensure it gets loaded in the right
order. I’m not sure how kosher this is, but it fixed the problem.
Personally my preferred solution is what is outline in the blog post:
have an initializer that requires stuff like that’
Guess i’m just dense, that worked great too. I had never used
initalizers/ before except to regulate inflections, just created an
Application.rb and threw in my
require ‘custom_validations’
Thanks Fred!!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.