lib/slavery.rb in slavery-1.2.0 vs lib/slavery.rb in slavery-1.3.0

- old
+ new

@@ -45,11 +45,13 @@ end end module ClassMethods def on_slave - context = scoped + # Why where(nil)? + # http://stackoverflow.com/questions/18198963/with-rails-4-model-scoped-is-deprecated-but-model-all-cant-replace-it + context = where(nil) context.slavery_target = :slave context end def connection_with_slavery @@ -80,9 +82,13 @@ # Create an anonymous AR class to hold slave connection def slave_connection_holder @slave_connection_holder ||= Class.new(ActiveRecord::Base) { self.abstract_class = true + + def self.name + "SlaveConnectionHolder" + end spec = ["#{Slavery.env}_slave", Slavery.env].find do |spec| ActiveRecord::Base.configurations[spec] end or raise Error.new("#{Slavery.env}_slave or #{Slavery.env} must exist!")