Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for #1458 - [3.1.0.rc1] App plugins initialized before engines and plugins inside engines #1735

Merged

Conversation

jhtwong
Copy link
Contributor

@jhtwong jhtwong commented Jun 16, 2011

Patch for #1458 - [3.1.0.rc1] App plugins initialized before engines 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.

…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.
josevalim added a commit that referenced this pull request Jun 16, 2011
…ing_patch

Patch for #1458 - [3.1.0.rc1] App plugins initialized before engines and plugins inside engines
@josevalim josevalim merged commit f24d8fa into rails:3-1-stable Jun 16, 2011
@josevalim
Copy link
Contributor

Can you send the same pull request for master please?

@jhtwong
Copy link
Contributor Author

jhtwong commented Jun 16, 2011

Patch for master submitted as #1737

jake3030 pushed a commit to jake3030/rails that referenced this pull request Jun 28, 2011
… was canceled or before_update was canceled

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[rails#1735 state:committed]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants