Forum: Ruby on Rails strange NoMethodError when trying to work in production mode

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.
006a4831843b48f6102d5d3cf92ae283?d=identicon&s=25 Shilo Ayalon (gte351s)
on 2009-04-30 17:41
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.
006a4831843b48f6102d5d3cf92ae283?d=identicon&s=25 Shilo Ayalon (gte351s)
on 2009-04-30 17:42
Shilo Ayalon 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 :)
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-30 18:05
(Received via mailing list)
On Apr 30, 4:41 pm, Shilo Ayalon <rails-mailing-l...@andreas-s.net>
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:
http://www.spacevatican.org/2008/11/21/environment...

Fred
006a4831843b48f6102d5d3cf92ae283?d=identicon&s=25 Shilo Ayalon (gte351s)
on 2009-05-03 08:16
Frederick Cheung wrote:
> On Apr 30, 4:41�pm, Shilo Ayalon <rails-mailing-l...@andreas-s.net>
> 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:
> http://www.spacevatican.org/2008/11/21/environment...
>
> 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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-03 11:26
(Received via mailing list)
On May 3, 7:16 am, Shilo Ayalon <rails-mailing-l...@andreas-s.net>
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
This topic is locked and can not be replied to.