# Error in production only: \`method\_missing': undefined method \`has\_attachment' for #\<Class:0xb72b6cb

**URL:** <https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727>\
**Category:** Rails\
**Created:** [June 7, 2009, 10:07pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727 "2009-06-07T22:07:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 10:07pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/1 "2009-06-07T22:07:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 10:08pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/2 "2009-06-07T22:08:46Z")

</div>

On Jun 7, 8:18 pm, Alastair [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/3 "2009-06-07T22:36:56Z")

</div>

On Jun 7, 9:08 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On Jun 7, 8:18 pm, Alastair [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 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?

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 11:06pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/4 "2009-06-07T23:06:46Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 11:02pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/5 "2009-06-07T23:02:40Z")

</div>

2009/6/7 Alastair [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > error I’m getting is as follows:  
> > > 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.

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 11:16pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/6 "2009-06-07T23:16:10Z")

</div>

On Jun 7, 10:01 pm, Alastair [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 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.

> 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 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 7, 2009, 11:29pm UTC](https://www.ruby-forum.com/t/error-in-production-only-method-missing-undefined-method-has-attachment-for-class-0xb72b6cb/169727/7 "2009-06-07T23:29:03Z")

</div>

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 🙂
