I was wrong.  A symbol didn't work, it just didn't throw an error.
>From the code below, can anyone see why I wouldn't be able to
namespace a Global::Helpers module and include it in MyApp::Helpers
and have the methods available?

This seems to be the way that Camping::BasicAuth works, are
views/helpers different?

---------- Forwarded message ----------
From: Joshua Schairbaum <[EMAIL PROTECTED]>
Date: May 7, 2007 2:31 PM
Subject: Module Madness
To: camping-list@rubyforge.org


I'm wanted to make a "global" module that I could include in my
application for some shared code between them.  I've been making
several camping apps and wanted them all to share a helper/partial
that contained the navigation.

I ran into a lot of difficulty when trying to include it, the primary
problem being "methodUndefined" errors.  I did finally get it to work,
but I'm not sure why.  Here's the relevant bits:

my_app.rb
MyApp::Helpers
  include Global::Helpers
  def month_name
     ...helper code
  end
end

MyApp::Views
  def layout
    ...some markaby
    :navigation #throws an UndefinedMethod error if not a symbol
    ...some more markaby
  end
end

global.rb
module Global
  module Helpers
    def navigation
      ...what i need
    end
  end
end

If I list the instance methods in irb, both "navigation" and
"month_name" shows up.  However, I have to use use :navigation as a
symbol in my view as opposed to just using month_name for the other.
Both are defined as instance methods.

What gives with the symbol usage?
_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to