Kian
2006-May-03 23:48 UTC
[Rails] const_missing & undefined method problems upgrading to Rails 1.1.2
Finally getting around to upgrading our application to Rails 1.1.2. Of course, nothing runs correctly after the upgrade. So far two major problems, perhaps related. Any help would be greatly appreciated. 1. We''re getting const_missing errors. Specifically when trying to use class constants in a custom helper method, being called from a layout template. The class constants were for controller classes (but not the current controller). Rails 1.0 (and previous) used to just find and load these automatically, but 1.1.2 throws an error. The weird thing is that it apparently only does this on some of the controller classes that are being referenced; the others load fine. I''ve checked that the class name to file name conversion via #demodulize.underscore seems to work OK. Did a little bit of debugging in active_support/dependencies.rb Module#const_missing (where the error occurs). It appears that other constant failures are being solved by the ''Attempt to access the name from the parent..'' bit of code, but not this one. I fixed this one with a brute force approach at the beginning of the helper: require "#{RAILS_ROOT}/app/controllers/*" but I''d rather not do that. 2. Now I''m getting ''undefined method'' errors from my templates (specifically in a template rendered from within another template, but not a partial). The methods in question are in a helper file that is included into application_helper.rb. In fact, it appears that none of the methods in my application_helper.rb are available in my view object (as listed by self.methods.sort.inspect). The ApplicationHelper module, and any modules that should be included in it, are not shown as ancestors in the template either (self.class.ancestors.inspect). Weirdly, the layout uses (different) methods from application_helper and its included modules without any problems whatsoever. Maybe I was playing fast & loose with previous versions of Rails, but I thought this upgrade was supposed to be painless. Any ideas, suggestions, etc? Thanks, Kian