Created
September 27, 2010 01:40
-
-
Save zdennis/598480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::Base | |
class << self | |
def establish_connection_with_activerecord_import(*args) | |
establish_connection_without_activerecord_import(*args) | |
ActiveSupport.run_load_hooks(:active_record_connection_established, connection) | |
end | |
alias_method_chain :establish_connection, :activerecord_import | |
end | |
end | |
ActiveSupport.on_load(:active_record_connection_established) do |connection| | |
if !ActiveRecord.const_defined?(:Import) || !ActiveRecord::Import.respond_to?(:load_from_connection) | |
require File.join File.dirname(__FILE__), "activerecord-import/base" | |
end | |
ActiveRecord::Import.load_from_connection connection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment