diff options
author | Washington Luiz <huoxito@gmail.com> | 2014-08-30 19:39:38 -0300 |
---|---|---|
committer | Washington Luiz <huoxito@gmail.com> | 2014-09-02 22:50:50 -0300 |
commit | 435e8d719cadb045cf7b194e2aafa766a67cd4bf (patch) | |
tree | 1ded2f716fec54153c967a51f0bb98d633622fbc /railties/lib | |
parent | d233d6e25ea6988f2be5710fa832dc4b18bfc496 (diff) | |
download | rails-435e8d719cadb045cf7b194e2aafa766a67cd4bf.tar.gz rails-435e8d719cadb045cf7b194e2aafa766a67cd4bf.tar.bz2 rails-435e8d719cadb045cf7b194e2aafa766a67cd4bf.zip |
Dont mess with default order engines load
When copying migrations some engines might depend on schema from other
engine so we can't blindly reverse all railties collection as that would
affect the order they were originally loaded. This patch helps to only
apply the order from engines specified in `railties_order`
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 6a4660bad0..67d5bac700 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -414,8 +414,14 @@ module Rails end end + # Return an array of railties respecting the order they're loaded + # and the order specified by the +railties_order+ config. + # + # While when running initializers we need engines in reverse + # order here when copying migrations from railties we need then in the same + # order as given by +railties_order+ def migration_railties # :nodoc: - (ordered_railties & railties_without_main_app).reverse + ordered_railties.flatten - [self] end protected @@ -448,11 +454,6 @@ module Rails super end - def railties_without_main_app # :nodoc: - @railties_without_main_app ||= Rails::Railtie.subclasses.map(&:instance) + - Rails::Engine.subclasses.map(&:instance) - end - # Returns the ordered railties for this application considering railties_order. def ordered_railties #:nodoc: @ordered_railties ||= begin @@ -472,13 +473,13 @@ module Rails index = order.index(:all) order[index] = all - order.reverse.flatten + order end end def railties_initializers(current) #:nodoc: initializers = [] - ordered_railties.each do |r| + ordered_railties.reverse.flatten.each do |r| if r == self initializers += current else |