class method
self.current_preventing_writes
Ruby on Rails 8.1.2
Since v6.1.7.10Signature
self.current_preventing_writes()
Returns the symbol representing the current setting for preventing writes.
ActiveRecord::Base.connected_to(role: :reading) do ActiveRecord::Base.current_preventing_writes #=> true end ActiveRecord::Base.connected_to(role: :writing) do ActiveRecord::Base.current_preventing_writes #=> false end
Source
# File activerecord/lib/active_record/core.rb, line 195
def self.current_preventing_writes
connected_to_stack.reverse_each do |hash|
return hash[:prevent_writes] if !hash[:prevent_writes].nil? && hash[:klasses].include?(Base)
return hash[:prevent_writes] if !hash[:prevent_writes].nil? && hash[:klasses].include?(connection_class_for_self)
end
false
end
Defined in activerecord/lib/active_record/core.rb line 195
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Core