Skip to content

Instantly share code, notes, and snippets.

@mnordin
Last active December 18, 2015 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnordin/80ce6ccf20cc3bccaef0 to your computer and use it in GitHub Desktop.
Save mnordin/80ce6ccf20cc3bccaef0 to your computer and use it in GitHub Desktop.
console usage without inverse_of
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