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

Replace use of return keyword as logic control inside AR transactions, as this is not supported in Ruby 3 #52

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

duknic
Copy link
Contributor

@duknic duknic commented Sep 30, 2024

Fixing the below deprecation warning as we prepare CRMP and associated plugins (i.e. this, draft_approve) for Ruby 3 upgrade.

DEPRECATION WARNING: Using `return`, `break` or `throw` to exit a transaction block is
deprecated without replacement. .... This results
in the transaction being committed, but in the next release of Rails
it will rollback.
 (called from in_new_draft_transaction_helper at /Users/38degrees/.rvm/gems/ruby-2.7.6/bundler/gems/draft_approve-ccf87a589661/lib/draft_approve/transaction.rb:85)

# and

/draft_approve/lib/draft_approve/models/draft_transaction.rb:60

I'll be the first to say this is not a pretty fix.
It tweaks some of the logic used inside Active Record transaction blocks to remove the old syntax and replaces it with variable assignments than then return stuff outside of the block. Thrilling stuff 😆

lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/models/draft_transaction.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/persistor.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/persistor.rb Dismissed Show dismissed Hide dismissed
lib/draft_approve/persistor.rb Dismissed Show dismissed Hide dismissed
@duknic duknic merged commit e0b6f23 into main Oct 7, 2024
6 checks passed
@duknic duknic deleted the fix-deprecated-ar-syntax branch October 7, 2024 21:36
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