patch to safe_fork to catch when the user has no connection before forking

This commit is contained in:
Nick Gauthier 2010-04-19 13:10:08 -04:00
parent 3c71985196
commit 361cd0724a
1 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ class SafeFork
begin
# create a new connection and perform the action
begin
ActiveRecord::Base.establish_connection(connection.merge({:allow_concurrency => true})) if defined?(ActiveRecord)
ActiveRecord::Base.establish_connection((connection || {}).merge({:allow_concurrency => true})) if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
# AR was defined but we didn't have a connection
end
@ -21,7 +21,7 @@ class SafeFork
ensure
# make sure we re-establish the connection before returning to the main instance
begin
ActiveRecord::Base.establish_connection(connection.merge({:allow_concurrency => true})) if defined?(ActiveRecord)
ActiveRecord::Base.establish_connection((connection || {}).merge({:allow_concurrency => true})) if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
# AR was defined but we didn't have a connection
end