Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding Back Rails::Engine::Railties#engines

Removing it breaks functionality with gems such as Thinking Sphinx.
This restores it with a deprecation warning. Closes #8551
  • Loading branch information...
commit 48d5a33269eac16e7927c8811bfdc6010a965959 1 parent cb2bd4a
@timraymond timraymond authored
View
6 railties/CHANGELOG.md
@@ -1,5 +1,11 @@
## Rails 4.0.0 (unreleased) ##
+* Restore Rails::Engine::Railties#engines with deprecation to ensure
+ compatibility with gems such as Thinking Sphinx
+ Fix #8551
+
+ *Tim Raymond*
+
* Add `-B` alias for `--skip-bundle` option in the rails new generators.
*Jiri Pospisil*
View
6 railties/lib/rails/application.rb
@@ -55,6 +55,7 @@ class Application < Engine
autoload :Bootstrap, 'rails/application/bootstrap'
autoload :Configuration, 'rails/application/configuration'
autoload :Finisher, 'rails/application/finisher'
+ autoload :Railties, 'rails/engine/railties'
autoload :RoutesReloader, 'rails/application/routes_reloader'
class << self
@@ -232,11 +233,6 @@ def helpers_paths #:nodoc:
config.helpers_paths
end
- def railties #:nodoc:
- @railties ||= Rails::Railtie.subclasses.map(&:instance) +
- Rails::Engine.subclasses.map(&:instance)
- end
-
protected
alias :build_middleware_stack :app
View
4 railties/lib/rails/engine.rb
@@ -468,6 +468,10 @@ def eager_load!
end
end
+ def railties
+ @railties ||= self.class::Railties.new
@spastorino Owner

Why was this done that way?.
Isn't something like this https://gist.github.com/spastorino/a917b488cc6088cc4b34 ok?
#9386

/cc @rafaelfranca @josevalim @drogus

@pixeltrix Owner

I'm guessing that @timraymond did it this way because that's how it is in 3-2-stable:
https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/engine.rb#L445

It used to be like your gist until @drogus changed it in 32a5b49.

@spastorino Owner

Pushed 45aabe6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+
# Returns a module with all the helpers defined for the engine.
def helpers
@helpers ||= begin
View
29 railties/lib/rails/engine/railties.rb
@@ -0,0 +1,29 @@
+module Rails
+ class Engine < Railtie
+ class Railties
+ include Enumerable
+ attr_reader :_all
+
+ def initialize
+ @_all ||= ::Rails::Railtie.subclasses.map(&:instance) +
+ ::Rails::Engine.subclasses.map(&:instance)
+ end
+
+ def self.engines
+ @engines ||= ::Rails::Engine.subclasses.map(&:instance)
+ end
+
+ def each(*args, &block)
+ _all.each(*args, &block)
+ end
+
+ def -(others)
+ _all - others
+ end
+
+ delegate :engines, to: "self.class"
+ end
+ end
+end
+
+ActiveSupport::Deprecation.deprecate_methods(Rails::Engine::Railties, :engines)
View
6 railties/test/railties/engine_test.rb
@@ -1241,6 +1241,12 @@ def index
assert_equal '/foo/bukkits/bukkit', last_response.body
end
+ test "engines method is properly deprecated" do
+ boot_rails
+
+ assert_deprecated { app.railties.engines }
+ end
+
private
def app
Rails.application
@pixeltrix

I'm guessing that @timraymond did it this way because that's how it is in 3-2-stable:
https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/engine.rb#L445

It used to be like your gist until @drogus changed it in 32a5b49.

Please sign in to comment.
Something went wrong with that request. Please try again.