Forum: Ruby on Rails method_missing only in production using custom validation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71ee1809f53df0a2b4dac0530f630933?d=identicon&s=25 Richard Schneeman (snowmaninthesun)
on 2009-01-15 05:00
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?

Rails 2.2.2, Ruby 1.8.6, Will-Paginate 2.3.6.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-15 11:24
(Received via mailing list)
On Jan 15, 4:00 am, Richard Schneeman <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?

My hunch would be because of
http://www.spacevatican.org/2008/11/21/environment...

Fred
71ee1809f53df0a2b4dac0530f630933?d=identicon&s=25 Richard Schneeman (snowmaninthesun)
on 2009-01-15 17:32
You were right.

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.


models/phrase.rb:
...
require 'custom_validations
validates_not_spam :word
...
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-15 18:13
(Received via mailing list)
On 15 Jan 2009, at 16:32, Richard Schneeman wrote:

>
> You were right.
>
> 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'
71ee1809f53df0a2b4dac0530f630933?d=identicon&s=25 Richard Schneeman (snowmaninthesun)
on 2009-01-15 20:46
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 topic is locked and can not be replied to.