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 [3.1.0.rc1] App plugins initialized before engines and plugins inside engines #1737

Merged

Conversation

jhtwong
Copy link
Contributor

@jhtwong jhtwong commented Jun 16, 2011

Patch for #1735 / #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
…patch

Patch for [3.1.0.rc1] App plugins initialized before engines and plugins inside engines
@josevalim josevalim merged commit a788d4e into rails:master Jun 16, 2011
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