Master Slave
By Tumayun.
Rails separate read and write.
Supported versions
- Ruby >= 2.0.0
- Rails >= 4.1.0
Install
Put this line in your Gemfile:
gem 'master_slave'
Then bundle:
% bundle
Usage
-
Run command
bundle exec rails g master_slave:config. -
Modify config/shards.yml.
Class User < ActiveRecord::Base
...
endRandom Slave
ActiveRecord::Base.slave do
User.all
endSpecified Slave
ActiveRecord::Base.using(:slave_name) do
User.all
endQuestions, Feedback
Feel free to message me on Github (tumayun) or Gmail (tumayun.2010@gmail.com).
Contributing to master_slave
- Fork, fix, then send me a pull request.