Skip to content

Commit 9131f08

Browse files
authored
[ci skip] Fix Grammatical Errors and Eliminate Ambiguous Wordings in Multiple Database Documents (rails#41670)
* Improve Readability of Guides on Multiple Databases * Add comma after the introductory clause. * Add backtick for the symbols used in the program. * `primary` * `false` * Add descriptive information on ambiguous words. * users => database users * use the first configuration => use the first configuration as default * a recent write => a recent write by the requesting user * for an environment => for each environment * both a `role` and `shard` => both a `role` and a `shard` * Add missing period at the end of a sentence. * Add double quote inside backtick [Rafael Mendonça França + Takumasa Ochi]
1 parent cb95c1b commit 9131f08

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

guides/source/active_record_multiple_databases.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ Let's add a replica for the first configuration, and a second database called an
5858
replica for that as well. To do this we need to change our `database.yml` from a 2-tier
5959
to a 3-tier config.
6060

61-
If a primary configuration is provided this will be used as the "default" configuration. If
62-
there is no configuration named "primary" Rails will use the first configuration for an
63-
environment. The default configurations will use the default Rails filenames. For example
64-
primary configurations will use `schema.rb` for the schema file whereas all other entries
61+
If a primary configuration is provided, it will be used as the "default" configuration. If
62+
there is no configuration named `"primary"`, Rails will use the first configuration as default
63+
for each environment. The default configurations will use the default Rails filenames. For example,
64+
primary configurations will use `schema.rb` for the schema file, whereas all the other entries
6565
will use `[CONFIGURATION_NAMESPACE]_schema.rb` for the filename.
6666

6767
```yaml
@@ -91,19 +91,19 @@ production:
9191
replica: true
9292
```
9393

94-
When using multiple databases there are a few important settings.
94+
When using multiple databases, there are a few important settings.
9595

9696
First, the database name for the `primary` and `primary_replica` should be the same because they contain
9797
the same data. This is also the case for `animals` and `animals_replica`.
9898

9999
Second, the username for the writers and replicas should be different, and the
100100
replica user's permissions should be set to only read and not write.
101101

102-
When using a replica database you need to add a `replica: true` entry to the replica in the
102+
When using a replica database, you need to add a `replica: true` entry to the replica in the
103103
`database.yml`. This is because Rails otherwise has no way of knowing which one is a replica
104104
and which one is the writer.
105105

106-
Lastly, for new writer databases you need to set the `migrations_paths` to the directory
106+
Lastly, for new writer databases, you need to set the `migrations_paths` to the directory
107107
where you will store migrations for that database. We'll look more at `migrations_paths`
108108
later on in this guide.
109109

@@ -161,7 +161,7 @@ clients have a limit to the number of open connections there can be and if you d
161161
multiply the number of connections you have since Rails uses the model class name for the
162162
connection specification name.
163163

164-
Now that we have the `database.yml` and the new model set up it's time to create the databases.
164+
Now that we have the `database.yml` and the new model set up, it's time to create the databases.
165165
Rails 6.0 ships with all the rails tasks you need to use multiple databases in Rails.
166166

167167
You can run `bin/rails -T` to see all the commands you're able to run. You should see the following:
@@ -192,7 +192,7 @@ rails db:schema:load:primary # Loads a database schema file (either
192192
```
193193

194194
Running a command like `bin/rails db:create` will create both the primary and animals databases.
195-
Note that there is no command for creating the users and you'll need to do that manually
195+
Note that there is no command for creating the database users, and you'll need to do that manually
196196
to support the readonly users for your replicas. If you want to create just the animals
197197
database you can run `bin/rails db:create:animals`.
198198

@@ -213,7 +213,7 @@ $ bin/rails generate migration CreateDogs name:string --database animals
213213
```
214214

215215
If you are using Rails generators, the scaffold and model generators will create the abstract
216-
class for you. Simply pass the database key to the command line
216+
class for you. Simply pass the database key to the command line.
217217

218218
```bash
219219
$ bin/rails generate scaffold Dog name:string --database animals
@@ -243,7 +243,7 @@ add this to the abstract class after you're done.
243243
Rails will only generate the new class once. It will not be overwritten by new scaffolds
244244
or deleted if the scaffold is deleted.
245245

246-
If you already have an abstract class and its name differs from `AnimalsRecord` you can pass
246+
If you already have an abstract class and its name differs from `AnimalsRecord`, you can pass
247247
the `--parent` option to indicate you want a different abstract class:
248248

249249
```bash
@@ -255,11 +255,11 @@ use a different parent class.
255255

256256
## Activating automatic connection switching
257257

258-
Finally, in order to use the read-only replica in your application you'll need to activate
258+
Finally, in order to use the read-only replica in your application, you'll need to activate
259259
the middleware for automatic switching.
260260

261261
Automatic switching allows the application to switch from the writer to replica or replica
262-
to writer based on the HTTP verb and whether there was a recent write.
262+
to writer based on the HTTP verb and whether there was a recent write by the requesting user.
263263

264264
If the application is receiving a POST, PUT, DELETE, or PATCH request the application will
265265
automatically write to the writer database. For the specified time after the write, the
@@ -371,7 +371,7 @@ end
371371
```
372372

373373
Then models can swap connections manually via the `connected_to` API. If
374-
using sharding both a `role` and `shard` must be passed:
374+
using sharding, both a `role` and a `shard` must be passed:
375375

376376
```ruby
377377
ActiveRecord::Base.connected_to(role: :writing, shard: :default) do
@@ -401,7 +401,7 @@ all databases globally. To use this feature you must first set
401401
configuration. The majority of applications should not need to make any other
402402
changes since the public APIs have the same behavior.
403403

404-
With `legacy_connection_handling` set to false, any abstract connection class
404+
With `legacy_connection_handling` set to `false`, any abstract connection class
405405
will be able to switch connections without affecting other connections. This
406406
is useful for switching your `AnimalsRecord` queries to read from the replica
407407
while ensuring your `ApplicationRecord` queries go to the primary.
@@ -458,6 +458,6 @@ will split the joins for you.
458458

459459
### Schema Cache
460460

461-
If you use a schema cache and multiple databases you'll need to write an initializer
461+
If you use a schema cache and multiple databases, you'll need to write an initializer
462462
that loads the schema cache from your app. This wasn't an issue we could resolve in
463463
time for Rails 6.0 but hope to have it in a future version soon.

0 commit comments

Comments
 (0)