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

Inspect reloaded object should maintain changes #22

Merged
merged 1 commit into from
Nov 17, 2021

Conversation

markedmondson
Copy link
Contributor

What is the purpose of this pull request?

Documents and fixes an issue found while using the gem. I can't quite understand what part of re-initializing and calling inspect causes the issue and would love to find out!

What changes did you make? (overview)

Clear the changes hash for an accessor if there are no changes to the attributes

Is there anything you'd like reviewers to focus on?

Why the hell does this happen? :D

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation (Readme)

Copy link
Owner

@palkan palkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

calling inspect causes the issue and would love to find out!

#inspect calls #attribute_for_inspect:
https://github.com/rails/rails/blob/6d3aedbbf27b89d0170a2ee024e7845c157e5697/activerecord/lib/active_record/attribute_methods.rb#L283-L288

Which calls _read_attribute and populate the defaults (making the original changes dirty).

@palkan palkan merged commit e7b22b7 into palkan:master Nov 17, 2021
@palkan
Copy link
Owner

palkan commented Nov 17, 2021

Released in 0.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants