-
Notifications
You must be signed in to change notification settings - Fork 45
Add support changing swapped_id, when called # reload
#27
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
Add support changing swapped_id, when called # reload
#27
Conversation
😭 company = Company.create(name: "Company")
Company.find(company.id).update(name: "NeoCompany")
company.reload
pp company.swapped_id # => 3
company.clear_changes_information
# Reset swapped_id after call `#clear_changes_information`
pp company.swapped_id # => 1 |
Fixed ⬆️ |
# NOTE: Hook to copying swapped_id | ||
@_swapped_id = fresh_object.swapped_id | ||
self | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrited ActiveRecord::Persistence#reload
.
https://github.com/rails/rails/blob/b9ca94caea2ca6a6cc09abaffaad67b447134079/activerecord/lib/active_record/persistence.rb#L602-L615
@meganemura @t-mori23 Please reviewing 🙏 |
# reload
# reload
@osyo-manga |
2b017b7
to
8f2524d
Compare
@t-mori23 oops, I fixed it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@t-mori23 @meganemura Thanks!!!! |
Fixed a bug that
swapped_id
doesn't change after#reload
.before
after