And I did some research and noticed that there is an API change between Rails 6.0 and 6.1.
Rails 6.0
# activerecord/lib/active_record/attribute_methods/read.rb
def _read_attribute(attr_name, &block) # :nodoc
sync_with_transaction_state if @transaction_state&.finalized?
@attributes.fetch_value(attr_name.to_s, &block)
end
Rails 6.1
# activerecord/lib/active_record/attribute_methods/read.rb
def _read_attribute(attr_name, &block) # :nodoc
@attributes.fetch_value(attr_name, &block)
end
The attr_name is no longer converted to String type. That led to fetching the incorrect identifier after storage.
So I change the code to use the public method read_attribute for avoiding internal API changes.
What does this PR address?
[ ] GitHub issue (Add reference - #XX)
[ ] Refactoring
[ ] New feature
[x] Bug fix
[ ] Adds more tests
Are tests included?
[x] Yes
[ ] No
Reviewer, please note:
Checklist:
[x] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
[x] I ran the full test suite before pushing the changes and all the tests pass.
Brief Summary of Changes
This PR is fixing the bug from my previous PR. (https://github.com/cloudinary/cloudinary_gem/pull/489) I found the issue I fixed in my previous PR is reproduced after I upgraded my project to Rails 6.1.
And I did some research and noticed that there is an API change between Rails 6.0 and 6.1.
Rails 6.0
Rails 6.1
The
attr_name
is no longer converted to String type. That led to fetching the incorrect identifier after storage. So I change the code to use the public methodread_attribute
for avoiding internal API changes.What does this PR address?
Are tests included?
Reviewer, please note:
Checklist: