Skip to content

Commit

Permalink
Patch for rails#1458 - [3.1.0.rc1] App plugins initialized before eng…
Browse files Browse the repository at this point in the history
…ines

and plugins inside engines

It seems that plugins inside a Rails 3.1 application proper (i.e. in
/vendor/plugins) are initialized before engines and plugins inside
engines.

After some debugging, I found the culprit in
Rails::Application::Railties#all:

  def all(&block)
    @ALL ||= railties + engines + super
    @all.each(&block) if block
    @ALL
  end

The call to super here implicitly passes the &block argument, which
has the unfortunate side-effect of adding the plugin initializers
first (in front of other railties and engines) in the case of
Rails::Engine#initializers:

def initializers
  initializers = []
  railties.all { |r| initializers += r.initializers }
  initializers += super
  initializers
end

The solution here is to replace the super call with a call
to #plugins.
  • Loading branch information
joseph-wong-sap committed Jun 16, 2011
1 parent f4db3d7 commit a89dfbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/application/railties.rb
Expand Up @@ -4,7 +4,7 @@ module Rails
class Application < Engine class Application < Engine
class Railties < Rails::Engine::Railties class Railties < Rails::Engine::Railties
def all(&block) def all(&block)
@all ||= railties + engines + super @all ||= railties + engines + plugins
@all.each(&block) if block @all.each(&block) if block
@all @all
end end
Expand Down

0 comments on commit a89dfbf

Please sign in to comment.