public
Description: The Rails Engines plugin
Homepage: http://rails-engines.org
Clone URL: git://github.com/lazyatom/engines.git
fix for rails plugin reloading (only call init once)
courtenay (author)
Sun Apr 27 21:20:32 -0700 2008
lazyatom (committer)
Mon Apr 28 08:53:18 -0700 2008
commit  f7656144b71685c06cfc04dbf41825358646b466
tree    d9899176688415992554ebde9ad4d279b287b1c6
parent  ffe8a9be8580510ffbe0f176110c303883d5575c
...
1
2
 
 
 
 
 
...
 
 
1
2
3
4
5
0
@@ -1,2 +1,5 @@
0
-Engines.init if defined? :Engines
0
-
0
+# Only call Engines.init once, in the after_initialize block so that Rails
0
+# plugin reloading works when turned on
1
+config.after_initialize do
0
+  Engines.init if defined? :Engines
0
+end

Comments

svenfuchs Mon Apr 28 11:44:35 -0700 2008 at init.rb L5

Hmm, this change actually seems to do the opposite of what the comment says. I get a “stack level too deep” error because Engines::RailsExtensions::AssetHelpers is included at server startup and subsequent requests (not the first request though). Thus, the asset helper methods get alias_chained again every time and an endless loop results.

When I revert that change and have Engines.init called only on plugin loading stage that behaviour vanishes.

The plugin’s init.rb file gets eval’d only once anyways, so I don’t get the rational behind this change at all … maybe that was one beer to much though ;)

lazyatom Mon Apr 28 14:44:42 -0700 2008

config.after_initialize shouldn’t be fired after every request – only at the end of initialization… hmm. Can you confirm that this block is called after every request?

svenfuchs Tue Apr 29 07:01:46 -0700 2008

Ok, you’re right, I were wrong. I still had this block from the Engines list in my development.rb which caused the difference:

config.after_initialize { Dependencies.load_once_paths = [] }

This causes Engines to be reloaded.

I still don’t get the rational behind that change though. :)