Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset has_one association when the related belongs_to association is set #43122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 13, 2021

  1. Reset has_one association when the related belongs_to association…

    … is set.
    
    When setting a `belongs_to` association the inverse `has_one` association is reset.
    
    Example:
    
    ```ruby
    jimmy = Author.create(name: "Jimmy Tolkien")
    david = Author.create(name: "DHH")
    post = jimmy.create_post(title: "The silly medallion", body: "")
    jimmy.post.update!(author: david)
    assert_nil jimmy.post
    ```
    
    Fixes rails#43096
    intrip committed Sep 13, 2021
    Copy the full SHA
    262c2ed View commit details
    Browse the repository at this point in the history