[Nitro] Possible bug in Controller#mount_at

James Britt james_b at neurogami.com
Sat Jun 3 00:42:24 EDT 2006

I've been trying to figure out the correct usage of 'mount_at' and was 
puzzled because it worked about half the time.

I tried putting it right at the start of my controller

class Main  < Nitro::Controller
   self.mount_at( "/main/" )

and I also tried putting it in run.rb:

Main.mount_at( "/main/" )

But still the templates for Main were not always found.  If I edited 
code while in debugging mode, certain classes got reload and then it 
would work.  But rarely would the templates path be correct right after 
a restart.

It seems that other (Nitro) code is calling 'mount_at', and my paths 
were getting boinked.  I looked at lib/nitro/controller.rb , and saw 
that 'mount_at' would always create an empty  @template_root, and then 
add some standard paths and whatever was passed to the method.

So I changed

     @template_root = []


    @template_root ||= []

And all was golden.

However, just because it works doesn't mean it is working the right way 
for the right reason.  But as best I can tell, each controller has 
'mount_at' called implicitly; additional calls to mount_at shouldn't be 
resetting the path, no?

James Britt

"You harmonize; then you customize."
  - Wilson Pickett

More information about the Nitro-general mailing list