提交 3ffc3635 编写于 作者: N Nursoltan Saipolda

fix some grammar errors on guide doc.

上级 d775176d
......@@ -1219,7 +1219,7 @@ clients.each do |client|
end
```
This code looks fine at the first sight. But the problem lies within the total number of queries executed. The above code executes 1 (to find 10 clients) + 10 (one per each client to load the address) = **11** queries in total.
This code looks fine at first sight. But the problem lies within the total number of queries executed. The above code executes 1 (to find 10 clients) + 10 (one per each client to load the address) = **11** queries in total.
**Solution to N + 1 queries problem**
......@@ -1453,7 +1453,7 @@ User.active.inactive
# SELECT "users".* FROM "users" WHERE "users"."state" = 'active' AND "users"."state" = 'inactive'
```
We can mix and match `scope` and `where` conditions and the final sql
We can mix and match `scope` and `where` conditions and the final SQL
will have all conditions joined with `AND`.
```ruby
......@@ -1750,7 +1750,7 @@ Client.connection.select_all("SELECT first_name, created_at FROM clients WHERE i
### `pluck`
`pluck` can be used to query single or multiple columns from the underlying table of a model. It accepts a list of column names as argument and returns an array of values of the specified columns with the corresponding data type.
`pluck` can be used to query single or multiple columns from the underlying table of a model. It accepts a list of column names as an argument and returns an array of values of the specified columns with the corresponding data type.
```ruby
Client.where(active: true).pluck(:id)
......
......@@ -64,7 +64,7 @@ controller-level validations. Here's a summary of the pros and cons:
* Controller-level validations can be tempting to use, but often become
unwieldy and difficult to test and maintain. Whenever possible, it's a good
idea to keep your controllers skinny, as it will make your application a
pleasure to work with in the long run.
pleasure to work within the long run.
Choose these in certain, specific cases. It's the opinion of the Rails team
that model-level validations are the most appropriate in most circumstances.
......
......@@ -171,7 +171,7 @@ Similarly, in the Rails console, if you have a user instance and reload:
> reload!
```
the `user` object is instance of a stale class object. Ruby gives you a new class if you evaluate `User` again, but does not update the class `user` is instance of.
the `user` object is an instance of a stale class object. Ruby gives you a new class if you evaluate `User` again, but does not update the class `user` is an instance of.
Another use case of this gotcha is subclassing reloadable classes in a place that is not reloaded:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册