instance method current_role

Ruby on Rails 6.0.6

Since v6.0.6 Last seen in v6.0.6

Signature

current_role()

Returns the symbol representing the current connected role.

ActiveRecord::Base.connected_to(role: :writing) do
  ActiveRecord::Base.current_role #=> :writing
end

ActiveRecord::Base.connected_to(role: :reading) do
  ActiveRecord::Base.current_role #=> :reading
end
Source
# File activerecord/lib/active_record/connection_handling.rb, line 148
    def current_role
      connection_handlers.key(connection_handler)
    end

Defined in activerecord/lib/active_record/connection_handling.rb line 148 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionHandling

Type at least 2 characters to search.

↑↓ navigate · open · esc close