Forum: Ruby on Rails Unable to include mixins with Rails 1.2 update

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Abb12830c57e6f8aa6da954229d317e7?d=identicon&s=25 Ned Wolpert (Guest)
on 2007-01-19 18:31
(Received via mailing list)

  I'm in the process of updating from 1.1.6 to 1.2.1.  Fixed deprecated
stuff, but this one I'm kinda stuck with.  I have an application
controller that is unable to include a mixin.  The dependencies.rb in
active support bails with this core message:

`load_missing_constant': Mail is not missing constant MailSidebar!

The Controller in this case starts with this:
class Mail::MailTypeController < ApplicationController
  include MailSidebar
  def index
    render :action => 'list'

And the sidebar is just this:
module Mail::MailSidebar
      "Mail Events"=> {:controller => "/mail/sendmail_event", :action
=> "list"},
      "Mail Templates"=> {:controller => "/mail/mail_template", :action
=> "list"},
      "Mail Types"=> {:controller => "/mail/mail_type", :action =>
  def sidebar?
  def sidebar_links

Any thoughts on where to look?  Of course, it works fine with Rails
1.1.6.  I've also noticed a problem where if I comment out all the
includes, and run the application, my application_helper methods only
work with the first page load, going to any page after the first one
for the controller fails until I restart the server.  I think there is
a problem with something in my environment and mixins, as the
application helper is just another module that is 'mixed in'.

Thanks for any help people can offer.
Abb12830c57e6f8aa6da954229d317e7?d=identicon&s=25 Ned Wolpert (Guest)
on 2007-01-19 18:52
(Received via mailing list)
Okay, I ended up solving the first problem by simply using the
namespace of the mixin, so the include now looks like this:

   include Mail::MailSidebar

which fixed my test cases.  Now, I still have the second problem I
mentioned, which still may be related, but I'm not sure how, or even
what to show to ask for help.  The issue is I have an application
helper that makes a set of calls to an object-graph that consists of
three different classes.  I get the following exception:
  undefined method `get_locale_strings' for #<Brand:0xb7922824>
which does exist in the Brand class itself.  (Remember, first time
loading the page this does not happen, only each time after the first)
The stack-trace looks like this:

app/models/organizational_unit.rb:103:in `create_locale_strings'
app/models/brand_maintainer.rb:66:in `get_locale_strings'
app/models/brand_maintainer.rb:54:in `get_locale_strings_by_user_id'
app/models/brand_maintainer.rb:193:in `get_user_locale'
app/models/brand_maintainer.rb:108:in `search_for_locale_string'
app/helpers/application_helper.rb:27:in `locale'

Which is kinda weird to me only that the stack trace doesn't include
the Brand class itself, but that may be not relevant... I'm not sure
how the stack propagates with  the missing_method.  Now, in the class
structure, BrandMaintainer is a singleton, OrganizationalUnit contains
a single brand... and the brand maintainer is manipulating the OU
above.  Specifically, in the method where the failure occurs, the
following is called:

hash = brand.get_locale_strings(lang)

and Brand does have in the brand.rb file, a method called:
  def get_locale_strings(lang=nil)

and I can see it called the first time though, but fails on each
existing one.  Any ideas on where to look for the bug in my code?
(Again, this worked in Rails 1.1.6, and I see the problem with Rails
Abb12830c57e6f8aa6da954229d317e7?d=identicon&s=25 Ned Wolpert (Guest)
on 2007-01-19 19:13
(Received via mailing list)
One more thing, then I'll wait for someone else to respond with an idea
on the problem...

If I set to cache my classes in config/development.rb, then I don't get
the problem described above.
 config.cache_classes = true
I'm trying to come up with a small test case to show it now.
Abb12830c57e6f8aa6da954229d317e7?d=identicon&s=25 Ned Wolpert (Guest)
on 2007-01-19 21:41
(Received via mailing list)
Okay, got the fix, figure I'd post this incase anyone else runs into
the same problem.

Turns out this issue is directly related to the fact that rails doesn't
'preload' in Rails 1.2.1 like it did with Rails 1.1.6... and the
problem I had was really isolated to a singleton class, my
BrandMaintainer, when it used objects that tried to load other objects.
 Once I added in the 'require' tags for each model object it needed, it
seems to work fine.

I'll be doing more tests and if I find anything else about this, I'll
post it too.
This topic is locked and can not be replied to.