-
-
Save mnordin/80ce6ccf20cc3bccaef0 to your computer and use it in GitHub Desktop.
console usage without inverse_of
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post = Post.first | |
=> #<Post id: 1, title: "First post"> | |
comment = post.comments.first | |
=> #<Comment id: 1, body: "I agree!", post_id: 1> | |
# Changing the post title in memory | |
post.title = "First post - revised" | |
post.title | |
=> "First post - revised" | |
comment.post.title | |
=> "First post" | |
# They are in fact the same object... | |
post == comment.post | |
=> true | |
# ...but different in-memory objects | |
post.title == comment.post.title | |
=> false | |
post.object_id | |
=> 70135767956700 | |
comment.post.object_id | |
=> 70135784070660 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment