README.md in distribute_reads-0.3.1 vs README.md in distribute_reads-0.3.2
- old
+ new
@@ -78,16 +78,22 @@
```ruby
users = distribute_reads { User.where(orders_count: 1) } # not executed yet
```
-Call `to_a` inside the block ensure the query runs on a replica.
+Call `to_a` or `load` inside the block to ensure the query runs on a replica.
```ruby
users = distribute_reads { User.where(orders_count: 1).to_a }
```
+You can automatically load relations returned from `distribute_reads` blocks by creating an initializer with:
+
+```ruby
+DistributeReads.eager_load = true
+```
+
## Options
### Replica Lag
Raise an error when replica lag is too high (specified in seconds)
@@ -179,11 +185,11 @@
end
```
## Rails 6
-Rails 6 has [native support for replicas](https://edgeguides.rubyonrails.org/active_record_multiple_databases.html) :tada:
+Rails 6 has [native support for replicas](https://guides.rubyonrails.org/active_record_multiple_databases.html) :tada:
```ruby
ActiveRecord::Base.connected_to(role: :reading) do
# do reads
end
@@ -206,15 +212,15 @@
- [Report bugs](https://github.com/ankane/distribute_reads/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/distribute_reads/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features
-To test, run:
+To get started with development and testing:
```sh
git clone https://github.com/ankane/distribute_reads.git
cd distribute_reads
createdb distribute_reads_test_primary
createdb distribute_reads_test_replica
-bundle
-bundle exec rake
+bundle install
+bundle exec rake test
```