Richard Schneeman
2009-Jan-15 04:00 UTC
method_missing only in production using custom validation
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-15 10:23 UTC
Re: method_missing only in production using custom validation
On Jan 15, 4:00 am, Richard Schneeman <rails-mailing-l...@andreas- s.net> wrote:> 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 errorshttp://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?My hunch would be because of http://www.spacevatican.org/2008/11/21/environment-rb-and-requiring-dependencies Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Richard Schneeman
2009-Jan-15 16:32 UTC
Re: method_missing only in production using custom validation
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 ... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Jan-15 17:12 UTC
Re: method_missing only in production using custom validation
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''> > models/phrase.rb: > ... > require ''custom_validations > validates_not_spam :word > ... > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Richard Schneeman
2009-Jan-15 19:46 UTC
Re: method_missing only in production using custom validation
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!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---