Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Everyone receives app as argument for consistency.

  • Loading branch information...
commit 52e01fc59dfcadaa0fd7773fb4d9a04dff297ce8 1 parent 76cebf2
@josevalim josevalim authored
View
4 activerecord/lib/active_record/railtie.rb
@@ -29,8 +29,8 @@ class Railtie < Rails::Railtie
# When loading console, force ActiveRecord::Base to be loaded
# to avoid cross references when loading a constant for the
# first time. Also, make it output to STDERR.
- console do |sandbox|
- require "active_record/railties/console_sandbox" if sandbox
+ console do |app|
+ require "active_record/railties/console_sandbox" if app.sandbox?
ActiveRecord::Base.logger = Logger.new(STDERR)
end
View
14 railties/lib/rails/application.rb
@@ -50,7 +50,9 @@ def inherited(base)
end
end
- attr_accessor :assets
+ attr_accessor :assets, :sandbox
+ alias_method :sandbox?, :sandbox
+
delegate :default_url_options, :default_url_options=, :to => :routes
# This method is called just after an application inherits from Rails::Application,
@@ -96,9 +98,9 @@ def initialize!
self
end
- def load_tasks
+ def load_tasks(app=self)
initialize_tasks
- railties.all { |r| r.load_tasks }
+ railties.all { |r| r.load_tasks(app) }
super
self
end
@@ -111,10 +113,10 @@ def load_generators(app=self)
self
end
- def load_console(sandbox=false)
+ def load_console(app=self)
initialize_console
- railties.all { |r| r.load_console(sandbox) }
- super()
+ railties.all { |r| r.load_console(app) }
+ super
self
end
View
3  railties/lib/rails/commands/console.rb
@@ -23,7 +23,8 @@ def start
opt.parse!(ARGV)
end
- @app.load_console(options[:sandbox])
+ @app.sandbox = options[:sandbox]
+ @app.load_console
if options[:debugger]
begin
View
2  railties/lib/rails/engine.rb
@@ -387,7 +387,7 @@ def find(path)
delegate :middleware, :root, :paths, :to => :config
delegate :engine_name, :isolated?, :to => "self.class"
- def load_tasks
+ def load_tasks(*)
super
paths["lib/tasks"].existent.sort.each { |ext| load(ext) }
end
View
10 railties/lib/rails/railtie.rb
@@ -173,18 +173,18 @@ def config
def eager_load!
end
- def load_console(sandbox=false)
- self.class.console.each { |block| block.call(sandbox) }
+ def load_console(app)
+ self.class.console.each { |block| block.call(app) }
end
- def load_tasks
+ def load_tasks(app)
extend Rake::DSL if defined? Rake::DSL
- self.class.rake_tasks.each(&:call)
+ self.class.rake_tasks.each { |block| block.call(app) }
# load also tasks from all superclasses
klass = self.class.superclass
while klass.respond_to?(:rake_tasks)
- klass.rake_tasks.each { |t| self.instance_exec(&t) }
+ klass.rake_tasks.each { |t| self.instance_exec(app, &t) }
klass = klass.superclass
end
end
View
7 railties/test/application/console_test.rb
@@ -10,7 +10,8 @@ def setup
def load_environment(sandbox = false)
require "#{rails_root}/config/environment"
- Rails.application.load_console(sandbox)
+ Rails.application.sandbox = sandbox
+ Rails.application.load_console
end
def test_app_method_should_return_integration_session
@@ -78,8 +79,8 @@ def test_with_sandbox
value = false
Class.new(Rails::Railtie) do
- console do |sandbox|
- value = sandbox
+ console do |app|
+ value = app.sandbox?
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.