Rails 6.1 adds support for role switching and sharding in database | Saeloun Blog

12-Jan-2021 1400
Rails 6.1 adds the ability to switch a role or shard for an application with multiple databases. This means it is possible to switch connections for one database instead of all databases globally.To use this feature, we need to set the below config in our application.config.active_record.legacy_connection_handling = falseLet’s say we have two databases, primary and vehicles. And we have shards and replica configured for each of them in database.yml as below:.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle