mirror of https://github.com/rails/rails
Merge pull request #46709 from cjilbert504/belongs-to-association-changed-guide-update
update return values to reflect the proper object class [ci-skip]
This commit is contained in:
commit
caaac482d5
|
@ -1006,10 +1006,10 @@ Does the same as `create_association` above, but raises `ActiveRecord::RecordInv
|
|||
The `association_changed?` method returns true if a new associated object has been assigned and the foreign key will be updated in the next save.
|
||||
|
||||
```ruby
|
||||
@book.author # => #<Book author_number: 123, author_name: "John Doe">
|
||||
@book.author # => #<Author author_number: 123, author_name: "John Doe">
|
||||
@book.author_changed? # => false
|
||||
|
||||
@book.author = Author.second # => #<Book author_number: 456, author_name: "Jane Smith">
|
||||
@book.author = Author.second # => #<Author author_number: 456, author_name: "Jane Smith">
|
||||
@book.author_changed? # => true
|
||||
|
||||
@book.save!
|
||||
|
@ -1021,10 +1021,10 @@ The `association_changed?` method returns true if a new associated object has be
|
|||
The `association_previously_changed?` method returns true if the previous save updated the association to reference a new associate object.
|
||||
|
||||
```ruby
|
||||
@book.author # => #<Book author_number: 123, author_name: "John Doe">
|
||||
@book.author # => #<Author author_number: 123, author_name: "John Doe">
|
||||
@book.author_previously_changed? # => false
|
||||
|
||||
@book.author = Author.second # => #<Book author_number: 456, author_name: "Jane Smith">
|
||||
@book.author = Author.second # => #<Author author_number: 456, author_name: "Jane Smith">
|
||||
@book.save!
|
||||
@book.author_previously_changed? # => true
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue