# Hack to fool AREL to make our multi-database relationships work. # Keep an eye on the following URL so when they fix this, we can gut this. # http://bit.ly/fiyHTh # # Install into config/initializers/arel_hack.rb # # This did look promising, but it seems to break "rake spec". When using # this code by default, it drops all the tables and then doesn't re-create # them (because it thinks they exist). Commenting this all out fixes that... # # module ActiveRecord # module ConnectionAdapters # module SchemaStatements # def table_exists?(table_name) # tables.include?(table_name) # #true # end # end # end # end # # Second fix as discovered on http://bit.ly/fzLofp module Arel class Table def table_exists? # If we're checking the other database, assume the table always exists. return @table_exists = true if name.to_s.include?(".") # Otherwise, use the stock Arel 2.0.9 method... @table_exists ||= tables.key?(@name) || engine.connection.table_exists?(name) end end end