You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/active_record_callbacks.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ The callback only runs when all the `:if` conditions and none of the `:unless` c
354
354
Callback Classes
355
355
----------------
356
356
357
-
Sometimes the callback methods that you'll write will be useful enough to be reused by other models. Active Record makes it possible to create classes that encapsulate the callback methods, so it becomes very easy to reuse them.
357
+
Sometimes the callback methods that you'll write will be useful enough to be reused by other models. Active Record makes it possible to create classes that encapsulate the callback methods, so they can be reused.
358
358
359
359
Here's an example where we create a class with an `after_destroy` callback for a `PictureFile` model:
Copy file name to clipboardExpand all lines: guides/source/active_record_validations.md
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -42,9 +42,8 @@ database. For example, it may be important to your application to ensure that
42
42
every user provides a valid email address and mailing address. Model-level
43
43
validations are the best way to ensure that only valid data is saved into your
44
44
database. They are database agnostic, cannot be bypassed by end users, and are
45
-
convenient to test and maintain. Rails makes them easy to use, provides
46
-
built-in helpers for common needs, and allows you to create your own validation
47
-
methods as well.
45
+
convenient to test and maintain. Rails provides built-in helpers for common
46
+
needs, and allows you to create your own validation methods as well.
48
47
49
48
There are several other ways to validate data before it is saved into your
50
49
database, including native database constraints, client-side validations and
@@ -77,7 +76,7 @@ example using the `new` method, that object does not belong to the database
77
76
yet. Once you call `save` upon that object it will be saved into the
78
77
appropriate database table. Active Record uses the `new_record?` instance
79
78
method to determine whether an object is already in the database or not.
80
-
Consider the following simple Active Record class:
79
+
Consider the following Active Record class:
81
80
82
81
```ruby
83
82
classPerson < ApplicationRecord
@@ -123,7 +122,7 @@ database only if the object is valid:
123
122
124
123
The bang versions (e.g. `save!`) raise an exception if the record is invalid.
125
124
The non-bang versions don't: `save` and `update` return `false`, and
126
-
`create`just returns the object.
125
+
`create` returns the object.
127
126
128
127
### Skipping Validations
129
128
@@ -204,7 +203,7 @@ end
204
203
# => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
205
204
```
206
205
207
-
`invalid?` is simply the inverse of `valid?`. It triggers your validations,
206
+
`invalid?` is the inverse of `valid?`. It triggers your validations,
208
207
returning true if any errors were found in the object, and false otherwise.
209
208
210
209
### `errors[]`
@@ -307,7 +306,7 @@ end
307
306
308
307
This validation is very specific to web applications and this
309
308
'acceptance' does not need to be recorded anywhere in your database. If you
310
-
don't have a field for it, the helper will just create a virtual attribute. If
309
+
don't have a field for it, the helper will create a virtual attribute. If
311
310
the field does exist in your database, the `accept` option must be set to
312
311
or include `true` or else the validation will not run.
313
312
@@ -1198,7 +1197,7 @@ validator type.
1198
1197
1199
1198
### `errors[:base]`
1200
1199
1201
-
You can add error messages that are related to the object's state as a whole, instead of being related to a specific attribute. You can use this method when you want to say that the object is invalid, no matter the values of its attributes. Since `errors[:base]` is an array, you can simply add a string to it and it will be used as an error message.
1200
+
You can add error messages that are related to the object's state as a whole, instead of being related to a specific attribute. You can use this method when you want to say that the object is invalid, no matter the values of its attributes. Since `errors[:base]` is an array, you can add a string to it and it will be used as an error message.
1202
1201
1203
1202
```ruby
1204
1203
classPerson < ApplicationRecord
@@ -1259,7 +1258,7 @@ validations fail.
1259
1258
Because every application handles this kind of thing differently, Rails does
1260
1259
not include any view helpers to help you generate these messages directly.
1261
1260
However, due to the rich number of methods Rails gives you to interact with
1262
-
validations in general, it's fairly easy to build your own. In addition, when
1261
+
validations in general, you can build your own. In addition, when
1263
1262
generating a scaffold, Rails will put some ERB into the `_form.html.erb` that
1264
1263
it generates that displays the full list of errors on that model.
Copy file name to clipboardExpand all lines: guides/source/association_basics.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -406,7 +406,7 @@ NOTE: Using `t.bigint :supplier_id` makes the foreign key naming obvious and exp
406
406
407
407
### Choosing Between `has_many :through` and `has_and_belongs_to_many`
408
408
409
-
Rails offers two different ways to declare a many-to-many relationship between models. The simpler way is to use `has_and_belongs_to_many`, which allows you to make the association directly:
409
+
Rails offers two different ways to declare a many-to-many relationship between models. The first way is to use `has_and_belongs_to_many`, which allows you to make the association directly:
410
410
411
411
```ruby
412
412
classAssembly < ApplicationRecord
@@ -2459,7 +2459,7 @@ Let's say we have Car, Motorcycle, and Bicycle models. We will want to share
2459
2459
the `color` and `price` fields and some methods for all of them, but having some
2460
2460
specific behavior for each, and separated controllers too.
2461
2461
2462
-
Rails makes this quite easy. First, let's generate the base Vehicle model:
2462
+
First, let's generate the base Vehicle model:
2463
2463
2464
2464
```bash
2465
2465
$ rails generate model vehicle type:string color:string price:decimal{10.2}
@@ -2503,7 +2503,7 @@ will generate the following SQL:
Copy file name to clipboardExpand all lines: guides/source/contributing_to_ruby_on_rails.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -48,9 +48,9 @@ Having a way to reproduce your issue will be very helpful for others to help con
48
48
49
49
These templates include the boilerplate code to set up a test case against either a released version of Rails (`*_gem.rb`) or edge Rails (`*_master.rb`).
50
50
51
-
Simply copy the content of the appropriate template into a `.rb` file and make the necessary changes to demonstrate the issue. You can execute it by running `ruby the_file.rb` in your terminal. If all goes well, you should see your test case failing.
51
+
Copy the content of the appropriate template into a `.rb` file and make the necessary changes to demonstrate the issue. You can execute it by running `ruby the_file.rb` in your terminal. If all goes well, you should see your test case failing.
52
52
53
-
You can then share your executable test case as a [gist](https://gist.github.com), or simply paste the content into the issue description.
53
+
You can then share your executable test case as a [gist](https://gist.github.com), or paste the content into the issue description.
0 commit comments