Error in production only: `method_missing': undefined method `has_attachment' for #<Class:0xb72b6cb0> (NoMethodError)

Hello guys,

I'm having a problem with running an application in production. The
error I'm getting is as follows:

/home/www/bandera/releases/20090607191259/vendor/rails/activerecord/
lib/active_record/base.rb:1964:in `method_missing': undefined method
`has_attachment' for #<Class:0xb72b6cb0> (NoMethodError)
  from /home/www/bandera/releases/20090607191259/app/models/document.rb:
8
  from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
  from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
  from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:158:in `require'
  from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:265:in
`require_or_load'
  from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:224:in `depend_on'
  from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:136:in
`require_dependency'
  from ./script/../config/../vendor/rails/railties/lib/initializer.rb:
393:in `load_application_classes'
   ... 13 levels...
  from /home/www/bandera/releases/20090607191259/vendor/rails/railties/
lib/commands/server.rb:84
  from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
  from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
  from ./script/server:3

This error occurs when I run './script/server -e production'. If I run
'./script/server' immediately afterwards, the site runs fine without
issue. I can't see for the life of me what could be causing this
problem and would appreciate any help!

Regards,

Alastair

Hello guys,

I'm having a problem with running an application in production. The
error I'm getting is as follows:

Random guess: is there is a line at the bottom of environment.rb that
requires whatever it is that provides the has_attachment method?

Fred

Hi Fred,

Thanks for your reply!

As regards to the line in environment.rb, there isn't. The
has_attachment, in this case, is the attachment_fu plugin. It works
fine on my local machine in both development and production modes. It
works on the remote server in development mode (with ./script/server)
but is literally just failing in production mode on the remote server
with ./script/server -e production. I completely fail to see what
could be causing this. Now copying the development.rb file over
production.rb on the remote server allows the application to run in
production mode so obviously there's something in the production.rb
environment file that is causing this error.

Alastair

In lieu of any better suggestions you could change it back to
production.rb one line at a time till you find the one causing the
problem.

Colin

In lieu of any better suggestions you could change it back to
production.rb one line at a time till you find the one causing the
problem.

I've been trying that also, without much success so far. I'll keep at
it though! this is possibly the most bizarre thing ever. I'm wondering
if I'm missing a gem somewhere so am updating the remote server with
all gems installed on my development machine.

I just tried removing any references to has_attachment from my models
and ran ./script/server -e production again. That cleared those errors
but now I'm getting a new error of:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:105:in `const_missing': uninitialized
constant User::Authentication (NameError)

I'm beginning to wonder if there's an issue with my rails app, in
production mode, not being able to see any plugins. Again, I can't
imagine why this would be occurring but it looks to be a possibility.

Alastair

Ok,

Turns out when I comment out any references to attachment_fu and
restful_authentication in my models, I can run the site in production
mode. Obviously this doesn't help as I need both those plugins
working :slight_smile: