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:
Jonathan Hefner 2022-12-12 21:49:18 -06:00 committed by GitHub
commit caaac482d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -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
```