Simen Brekken
2005-Jul-26 08:57 UTC
FCGI production mode association const_missing errors.
I''m having weird association problems with FCGI in production mode, I''ve two models: class Header < ActiveRecord::Base has_one :image, :class_name => "HeaderImage", :foreign_key => "parent_id", :dependent => true end class Banner < ActiveRecord::Base has_one :image, :class_name => "BannerImage", :foreign_key => "parent_id", :dependent => true end ... both the BannerImage and HeaderImage are descendants of Image which again is a descendant of Attachment. However, in development mode calling @header.image from my inside my show action template works perfectly. Today I tried deploying the application into production on a lighttpd/fcgi server and this started showing up (see error message in bottom of mail). Running the application in production with Webrick works. Switching dependancy from require to load does not fix it, so does disabling caching. What puzzles me is that the Banner and Header tables and models does not differ in any way other than an extra VARCHAR field. The BannerImage and HeaderImage models are identical except for an after_save. This error also happens with another model Article which has_one ArticleImage implemented in the same way. -- ERROR LOG -- ActionView::TemplateError (/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in `const_missing'': uninitialized constant HeaderImage) on line #15 of /admin/headers/show.rhtml: 12: <div class="form"> 13: <label>Name:</label> <span class="static"><%= @header.name %></span><br/> 14: <label>Header:</label> <span class="static"><%= @header.category.name %></span><br/> 15: <% if @header.image %> 16: <label>Image:</label> 17: <%= image_tag @header.image.uri %> 18: <% end %> /gems/activerecord-1.11.1/lib/active_record/associations/association_proxy.rb:11:in `initialize'' (eval):1:in `initialize'' /gems/activerecord-1.11.1/lib/active_record/associations/has_one_association.rb:5:in `eval'' /gems/activerecord-1.11.1/lib/active_record/associations/association_proxy.rb:11:in `initialize'' /gems/activerecord-1.11.1/lib/active_record/associations/has_one_association.rb:5:in `initialize'' /gems/activerecord-1.11.1/lib/active_record/associations.rb:607:in `new'' /gems/activerecord-1.11.1/lib/active_record/associations.rb:607:in `image'' /gems/activerecord-1.11.1/lib/active_record/associations.rb:603:in `image'' (erb):15:in `evaluate_locals'' /gems/actionpack-1.9.1/lib/action_view/base.rb:272:in `evaluate_locals'' /gems/actionpack-1.9.1/lib/action_view/base.rb:283:in `rhtml_render'' /gems/actionpack-1.9.1/lib/action_view/base.rb:208:in `send'' /gems/actionpack-1.9.1/lib/action_view/base.rb:208:in `render_template'' /gems/actionpack-1.9.1/lib/action_view/base.rb:173:in `render_file'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:588:in `render_with_no_layout'' /gems/actionpack-1.9.1/lib/action_controller/layout.rb:216:in `render_without_benchmark'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `measure'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:591:in `render_with_no_layout'' /gems/actionpack-1.9.1/lib/action_controller/layout.rb:216:in `render_without_benchmark'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `measure'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:604:in `render_with_no_layout'' /gems/actionpack-1.9.1/lib/action_controller/layout.rb:216:in `render_without_benchmark'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `measure'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:627:in `render_with_no_layout'' /gems/actionpack-1.9.1/lib/action_controller/layout.rb:210:in `render_without_benchmark'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `measure'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:25:in `render'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:757:in `perform_action_without_filters'' /gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in `perform_action_without_benchmark'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `measure'' /gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'' /gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in `perform_action'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `send'' /gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `process'' /gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'' /gems/rails-0.13.1/lib/fcgi_handler.rb:144:in `process_request'' /gems/rails-0.13.1/lib/fcgi_handler.rb:64:in `process!'' /gems/rails-0.13.1/lib/fcgi_handler.rb:55:in `each_cgi'' /gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each'' /gems/fcgi-0.8.6.1/./fcgi.rb:597:in `each_cgi'' /gems/rails-0.13.1/lib/fcgi_handler.rb:55:in `process!'' /gems/rails-0.13.1/lib/fcgi_handler.rb:21:in `process!'' /var/www/.../public/dispatch.fcgi:24 -- SIMEN BREKKEN / born to synthesize.
Tim Lucas
2005-Jul-26 15:30 UTC
Re: FCGI production mode association const_missing errors.
On 26/07/2005, at 6:57 PM, Simen Brekken wrote:> -- ERROR LOG -- > ActionView::TemplateError > (/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/ > dependencies.rb:186:in `const_missing'': uninitialized constant > HeaderImage) on line #15 of /admin/headers/show.rhtml:Have you added the relevant "model" declarations in the controller class? - tim
Simen Brekken
2005-Jul-26 15:59 UTC
Re: FCGI production mode association const_missing errors.
Yes, both model :banner and model :banner_image with no change in result. As I said it works with Webrick in production mode. SIMEN BREKKEN / born to synthesize. Tim Lucas wrote:> On 26/07/2005, at 6:57 PM, Simen Brekken wrote: > >> -- ERROR LOG -- >> ActionView::TemplateError >> (/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/ >> dependencies.rb:186:in `const_missing'': uninitialized constant >> HeaderImage) on line #15 of /admin/headers/show.rhtml: > > > Have you added the relevant "model" declarations in the controller class? > > - tim
Simen Brekken
2005-Jul-27 08:33 UTC
Re: FCGI production mode association const_missing errors.
Simen Brekken wrote:> I''m having weird association problems with FCGI in production mode, I''ve > two models:I''ve now tracked the problem down to a require statement in the failing models: require ''RMagick'' class BannerImage < Attachment end Even though there is no name-collision this require statement gives me: ActionView::TemplateError (/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in `const_missing'': uninitialized constant BannerImage) on line #16 of /admin/banners/show.rhtml: I have yet to solve the problem since I need RMagick for generating thumbnails and some image effects, so if anyone has a solution to this it would be greatly appriciated. -- Simen Brekken