New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActiveRecord::Base.connected_to? #34680

merged 1 commit into from Dec 12, 2018


None yet
3 participants
Copy link

jhawthorn commented Dec 11, 2018

This can be used to check the currently connected role. It's meant to mirror ActiveRecord::Base.connected_to introduced in #34052


ActiveRecord::Base.connected_to(role: :writing) do
  ActiveRecord::Base.connected_to?(role: :writing) #=> true
  ActiveRecord::Base.connected_to?(role: :reading) #=> false

cc @eileencodes

@rails-bot rails-bot bot added the activerecord label Dec 11, 2018

@eileencodes eileencodes self-assigned this Dec 11, 2018

Copy link

eileencodes left a comment

Looks great! Will merge once tests are green.


This comment has been minimized.

Copy link

eileencodes commented Dec 11, 2018

Sign codeclimate. We use assert_not over refute, can you update?

current_role == role.to_sym

def current_role

This comment has been minimized.


rafaelfranca Dec 11, 2018


Is this a public API method? If yes, it needs to be documented.

Add AR::Base.connected_to?
This can be used to check the currently connected role. It's meant to
mirror AR::Base.connected_to

@jhawthorn jhawthorn force-pushed the jhawthorn:connected_to_question branch from 23b70db to b67a3f5 Dec 11, 2018

@eileencodes eileencodes merged commit beb63b2 into rails:master Dec 12, 2018

2 checks passed

codeclimate All good!
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment