Forum: Ruby on Rails Error in production only: `method_missing': undefined method `has_attachment' for #<Class:0xb72b6cb

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.
7c062e53f97e8ec147fee8afeae66b4f?d=identicon&s=25 Alastair (Guest)
on 2009-06-07 22:07
(Received via mailing list)
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-06-07 22:08
(Received via mailing list)
On Jun 7, 8:18 pm, Alastair <m...@alastairmoore.com> 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
7c062e53f97e8ec147fee8afeae66b4f?d=identicon&s=25 Alastair (Guest)
on 2009-06-07 22:36
(Received via mailing list)
On Jun 7, 9:08 pm, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> On Jun 7, 8:18 pm, Alastair <m...@alastairmoore.com> 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
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-06-07 23:02
(Received via mailing list)
2009/6/7 Alastair <mail@alastairmoore.com>:
>> > 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
7c062e53f97e8ec147fee8afeae66b4f?d=identicon&s=25 Alastair (Guest)
on 2009-06-07 23:06
(Received via mailing list)
> 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.
7c062e53f97e8ec147fee8afeae66b4f?d=identicon&s=25 Alastair (Guest)
on 2009-06-07 23:16
(Received via mailing list)
On Jun 7, 10:01 pm, Alastair <m...@alastairmoore.com> 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
7c062e53f97e8ec147fee8afeae66b4f?d=identicon&s=25 Alastair (Guest)
on 2009-06-07 23:29
(Received via mailing list)
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 :)
This topic is locked and can not be replied to.