diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-04 16:39:01 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-04 16:47:35 +0200 |
commit | 92661b0c501a65b7f2d9ac8fbf9743152b8a031b (patch) | |
tree | b49e621c5db5b3ba72a1952577c863193b916e16 /railties/lib | |
parent | b9bba555caa95389e97bd7d32472ddc1e429d7c2 (diff) | |
download | rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.tar.gz rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.tar.bz2 rails-92661b0c501a65b7f2d9ac8fbf9743152b8a031b.zip |
Move sandbox to AR and pass the sandbox as a value. This way, other ORMs like Datamapper can also have their own sandboxing in rails console.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/console/sandbox.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 4 |
3 files changed, 3 insertions, 10 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 4e82761e5d..dd01bbab1d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -112,7 +112,7 @@ module Rails def load_console(sandbox=false) initialize_console(sandbox) - railties.all { |r| r.load_console } + railties.all { |r| r.load_console(sandbox) } super() self end @@ -196,7 +196,6 @@ module Rails def initialize_console(sandbox=false) require "rails/console/app" - require "rails/console/sandbox" if sandbox require "rails/console/helpers" end end diff --git a/railties/lib/rails/console/sandbox.rb b/railties/lib/rails/console/sandbox.rb deleted file mode 100644 index 65a3d68619..0000000000 --- a/railties/lib/rails/console/sandbox.rb +++ /dev/null @@ -1,6 +0,0 @@ -ActiveRecord::Base.connection.increment_open_transactions -ActiveRecord::Base.connection.begin_db_transaction -at_exit do - ActiveRecord::Base.connection.rollback_db_transaction - ActiveRecord::Base.connection.decrement_open_transactions -end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 7fca565124..b183eb8ddd 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -173,8 +173,8 @@ module Rails def eager_load! end - def load_console - self.class.console.each(&:call) + def load_console(sandbox=false) + self.class.console.each { |block| block.call(sandbox) } end def load_tasks |