Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created February 16, 2009 20:37
Show Gist options
  • Save brandon-beacher/65348 to your computer and use it in GitHub Desktop.
Save brandon-beacher/65348 to your computer and use it in GitHub Desktop.
def self.connect_each(&block)
ordered.each do |customer|
ActiveRecord::Base.establish_connection customer.environment
begin
next unless ActiveRecord::Base.connection.active?
yield customer
rescue
next
end
end
# TODO: restore the original connection before returning
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment