16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/use_db/migration.rb', line 16
def method_missing_with_connection_swap(method, *arguments, &block)
say_with_time "#{method}(#{arguments.map { |a| a.inspect }.join(", ")})" do
arguments[0] = ActiveRecord::Migrator.proper_table_name(arguments.first
) unless arguments.empty? || method == :execute
if (self.respond_to?(:database_model))
write "Using custom database model's connection (#{self.database_model}) for this migration"
eval("#{self.database_model}.connection.send(method, *arguments, &block)")
else
ActiveRecord::Base.connection.send(method, *arguments, &block)
end
end
end
|