Forum: Ruby on Rails const_missing & undefined method problems upgrading to Rails

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.
27f8beb57f4d56d328749b51ac886d2c?d=identicon&s=25 Kian (Guest)
on 2006-05-04 01:48
(Received via mailing list)
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
This topic is locked and can not be replied to.