Sha256: 805c5be09d56c026ddfc513c140b6a6af27fb074eb78fd53525dea9e31ae98f6
Contents?: true
Size: 741 Bytes
Versions: 3
Compression:
Stored size: 741 Bytes
Contents
module ActiveRecord class Base class << self alias_method :connection_without_standby, :connection def connection case Thread.current[:_standby] when :primary, NilClass connection_without_standby else Standby.connection_holder(Thread.current[:_standby]).connection_without_standby end end # Generate scope at top level e.g. User.on_standby def on_standby(name = :null_state) # 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.standby_target = name || :null_state context end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
standby-5.0.0 | lib/standby/active_record/base.rb |
slavery-4.0.0 | lib/standby/active_record/base.rb |
standby-4.0.0 | lib/standby/active_record/base.rb |