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.

I'm about to release my app (was going to today), but have found a last
minute bug that I'm have difficulty tying down, never mind fix. It's
occurring sporadically, and is fixed (temporarily) by restarting the
instance of the mongrel, but is not always caused by the same page.
Honestly, I'm not sure I know where to start trying to track it down,
and any help would be appreciated.
What's happening is this. If I hit one particular page (have observed
this on only two pages so far but of course may affect others) with
photos on it a number of times it renders fine (the photos are linked to
the model via attachment_fu, which is using Image Science, not RMagick).
Then suddenly, it blows up, with one of two errors. The first error is
the following (can post full stack trace if anyone thinks it's useful):
A ActionView::TemplateError occurred in modtypes#show:
exit
On line #1 of app/views/shared/_main_photo.rhtml
1: <% if main_photo.medium_image_url %>
2: <div class="main_photo">
3: <%= link_to image_tag(main_photo.medium_image_url, {:alt =>
main_photo.title, :title => main_photo.caption}), photo_path(main_photo)
%>
4: <div class="caption"><%= link_to(
truncate(main_photo.caption,80, "... see more"), photo_path(main_photo))
if main_photo.caption %></div>
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:70:in `exit'
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:70:in
`rootdir'
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:84:in
`directory'
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:257:in
`so_name'
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:291:in
`load_cache'
/usr/lib/ruby/gems/1.8/gems/RubyInline-3.6.2/inline.rb:627:in
`inline'
/usr/lib/ruby/gems/1.8/gems/image_science-1.1.1/lib/image_science.rb:84
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:32:in
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:32:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
`new_constants_in'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb:1
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
`new_constants_in'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in
`require_or_load'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:249:in
`load_missing_constant'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in
`const_missing'
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:82:in
`const_get'
#{RAILS_ROOT}/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:82:in
`has_attachment'
#{RAILS_ROOT}/app/models/photo_image.rb:8
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
`new_constants_in'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in
`require_or_load'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:249:in
`load_missing_constant'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in
`const_missing'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:465:in
`const_missing'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1355:in
`compute_type'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:125:in
`send'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:125:in
`klass'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:129:in
`table_name'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb:74:in
`construct_sql'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb:6:in
`initialize'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations.rb:882:in
`new'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations.rb:882:in
`photo_image'
#{RAILS_ROOT}/app/models/photo.rb:45:in `medium_image_url'
#{RAILS_ROOT}/app/views/shared/_main_photo.rhtml:1:in
`_run_rhtml_47app47views47shared47_main_photo46rhtml'
Then if the same instance is hit again it returns a slightly different
error:
A ActionView::TemplateError occurred in modtypes#show:
Expected
/home/frankg/sites/carstuff/current/config/../app/models/photo_image.rb
to define PhotoImage
On line #1 of app/views/shared/_main_photo.rhtml
1: <% if main_photo.medium_image_url %>
2: <div class="main_photo">
3: <%= link_to image_tag(main_photo.medium_image_url, {:alt =>
main_photo.title, :title => main_photo.caption}), photo_path(main_photo)
%>
4: <div class="caption"><%= link_to(
truncate(main_photo.caption,80, "... see more"), photo_path(main_photo))
if main_photo.caption %></div>
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:250:in
`load_missing_constant'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:453:in
`const_missing'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/dependencies.rb:465:in
`const_missing'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1355:in
`compute_type'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:125:in
`send'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:125:in
`klass'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/reflection.rb:129:in
`table_name'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb:74:in
`construct_sql'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb:6:in
`initialize'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations.rb:882:in
`new'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/associations.rb:882:in
`photo_image'
#{RAILS_ROOT}/app/models/photo.rb:45:in `medium_image_url'
#{RAILS_ROOT}/app/views/shared/_main_photo.rhtml:1:in
`_run_rhtml_47app47views47shared47_main_photo46rhtml'
While all this is going on, the other mongrel instances are serving up
the page with no probs. I'm running Ruby 1.8.5 with Rails 1.2.1
(frozen), on a number of Xen instances running Debian etch.
The page above is simply a 'show' page. There's no dynamic resizing of
photos, or anything like that (so not sure why Image Science is being
invoked in the first error). It's a really very straightforward page
from a controller/view perspective.
If anyone has any ideas, or point me towards a strategy for tracking
down the problem, I'd be very grateful.
Many thanks
Chris

Hi Chris,
I have exactly the same problem here, with the following config: Debian
Sarge, ruby 1.8.4, Rails 1.2.3 (with some patches backported from
trunk), attachment_fu (revision 2834), RubyInline 3.6.2, mongrel 1.0.1.
The two same errors are happening on view-only pages, if an image exists
or not (model with attachment_fu).
Have you found a solution?
Thanks,
Philippe

Philippe Jayet wrote:
>> Thanks,>> Philippe>>
It was as Ezra said:
Monit starts your mongrels with a fully clean environemnt. Meaning
none of your normal ENV vars are set. WHat you need to do is put
this
in the top of your environment.rb
ENV['HOME'] = "/home/foobar"
Then restart monit and all the mongrels. This will fix the
problem.
It's all working lovely now :-)
Hope this helps
Chris
--
----------------------------
http://www.autopendium.co.uk
Stuff about old cars