Strange NoMethodError when trying to work in production mode

Hi - I’m trying to see how my app behaves in production environment by
running the development server with -e production:
appdir~$ ./script/server -p production
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1964:in
method_missing': undefined method validates_positivity_of’ for
#Class:0xb6d8cb40 (NoMethodError)
from /home/gtman/work/rails/bar/app/models/commission.rb:7
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in require’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:158:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:265:in require_or_load’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:224:in
depend_on' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:136:in require_dependency’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:393:in
load_application_classes' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:392:in each’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:392:in
load_application_classes' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:390:in each’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:390:in
load_application_classes' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:195:in process’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in
send' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in run’
from /home/gtman/work/rails/bar/config/environment.rb:14
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in require’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in new_constants_in’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from ./script/server:3 from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:392:in load_application_classes’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:390:in
each' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:390:in load_application_classes’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:195:in
process' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in send’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in
run' from /home/shilo/work/rails/bar/config/environment.rb:14 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in require’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in
new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in require’
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in require’
from ./script/server:3

my validations are in a file inside lib folder: http://pastie.org/463883

Not so sure what I’m doing wrong, since all of that worked great while
in development mode. I’d appreciate any help offered - thanks.

Shilo A. wrote:

Hi - I’m trying to see how my app behaves in production environment by
running the development server with -e production:
appdir~$ ./script/server -p production

the above should obviously be ./script/server -e production
that’s just a typo on my part.

still could use help :slight_smile:

On Apr 30, 4:41 pm, Shilo A. [email protected]
wrote:

my validations are in a file inside lib folder:http://pastie.org/463883

Not so sure what I’m doing wrong, since all of that worked great while
in development mode. I’d appreciate any help offered - thanks.

see this blog post I wrote a few months ago:

Fred

On May 3, 7:16 am, Shilo A. [email protected]
wrote:

I read your post, which made sense. So, I moved all my requires into the
initializer in the environment.rb file.

Rails then complained that it couldn’t find active record, so I added
require ‘activerecord’, though it didn’t seem right (rails should know
what that is). It then complained it doesn’t know what the downcase
method (“Some string”.downcase) is, which seems pretty basic… so I’m
not sure what I’m messing up.

My blog post obviously wasn’t clear enough - I meant put your require
inside an initializer in config/initializers

Fred

Frederick C. wrote:

On Apr 30, 4:41�pm, Shilo A. [email protected]
wrote:

my validations are in a file inside lib folder:http://pastie.org/463883

Not so sure what I’m doing wrong, since all of that worked great while
in development mode. I’d appreciate any help offered - thanks.

see this blog post I wrote a few months ago:
environment.rb and requiring dependencies - Space Vatican

Fred

I read your post, which made sense. So, I moved all my requires into the
initializer in the environment.rb file.

Rails then complained that it couldn’t find active record, so I added
require ‘activerecord’, though it didn’t seem right (rails should know
what that is). It then complained it doesn’t know what the downcase
method (“Some string”.downcase) is, which seems pretty basic… so I’m
not sure what I’m messing up.

my file:

RAILS_GEM_VERSION = ‘2.3.2’ unless defined? RAILS_GEM_VERSION

require File.join(File.dirname(FILE), ‘boot’)

Rails::Initializer.run do |config|

#… some default configs, like session, timezone

require ‘rubygems’
require ‘activerecord’
require ‘lib/custom_validations’
require ‘will_paginate’

end