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

Fix obtaining identifier on rails >= 6.1 #493

Conversation

david-zw-liu
Copy link
Contributor

Brief Summary of Changes

This PR is fixing the bug from my previous PR. (#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

# 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
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

@const-cloudinary const-cloudinary merged commit 1e46eff into cloudinary:master Jul 14, 2022
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