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 for set_attribute_was patch issue and Rails 7 support #434

Merged
merged 7 commits into from
Mar 28, 2023

Conversation

vimalvnair
Copy link
Contributor

This fixes the issue mentioned in PR: #431 , created by @mvastola

I am using the write_cast_value method from ActiveModel instead of the removed set_attribute_was to manage virtual attributes. This will work for Rails version 5.2 and higher. I locally ran the tests for all the rails versions mentioned in travis.yml and the tests are passing for all. I couldn't find a way to push the fix to the above PR, some I am creating a new one.

I have tested the fix with our internal app and have not encountered any issues. However, I recommend that others also test it with their applications.

I have also included the changes for Rails 7 support which fixes #423 . These changes were taken from PR: #425, created by @movermeyer. I couldn't find a way to contribute to that. I suggest reviewing the PR and the conversations there for additional context.

After these changes attr_encrypted should start working with Rails 7

joshbranham and others added 6 commits December 16, 2022 08:07
Signed-off-by: Josh Branham <josh.php@gmail.com>
As those should be passing or otherwise dealt with by the
time this is merged
…r Rails >= 5.2

Use #write_cast_value instead of #set_attribute_was patch
… with Rails 7

Prefix 'attr_encrypted' to encrypt and decrypt methods to avoid clash with Rails 7

Adopted from PR: attr-encrypted#425
@vimalvnair
Copy link
Contributor Author

vimalvnair commented Mar 18, 2023

The checks are failing for only Ruby 2.6.10. Caused by:

sqlite3-1.6.1-x86_64-linux requires ruby version >= 2.7, < 3.3.dev, which is
incompatible with the current version, ruby 2.6.10p210

Tests for all versions of Rails, with Ruby 2.7.6 are passing in Travis

Please feel free to suggest a solution for this.

@vimalvnair
Copy link
Contributor Author

sqlite3 v1.6.0 and above removed the native gem support for ruby 2.6: sparklemotion/sqlite3-ruby#367 . So I am hardcoding the sqlite3 version to 1.5.4 in gemspec.

We can also think about dropping the support for ruby 2.6

All the tests are passing now.

cc: @joshbranham @mvastola

@joshbranham
Copy link
Member

Thanks @vimalvnair this looks great to me. @mvastola any concerns?

@mikevoets
Copy link

When this gets merged (hopefully soon 🎉 ), will this be packaged into a release right after? :-)

Copy link
Member

@mvastola mvastola left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for doing this, all!

@mvastola mvastola merged commit de318e0 into attr-encrypted:master Mar 28, 2023
@vimalvnair
Copy link
Contributor Author

Thank you @mvastola @joshbranham for looking into this.

@vimalvnair
Copy link
Contributor Author

@mvastola @joshbranham Can we also package this into a release?

@joshbranham
Copy link
Member

Resolves #425

@vimalvnair working on it in #435

mjankowski added a commit to mjankowski/devise-two-factor that referenced this pull request Apr 11, 2023
As of version 4.0.0, attr_encrypted supports Rails 7.

This change relaxes the version requirement for attr_encrypted so that
there's a path to upgrade to Rails 7 while staying in the
`devise-two-factor` 4.x series, for apps who are ready for the Rails
update but not yet ready for the `devise-two-factor` 5.x update.

Relevant attr_encrypted version: attr-encrypted/attr_encrypted@b565876
Rails 7 changes: attr-encrypted/attr_encrypted#434
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.

Undefined method #key? for nil:NilClass
4 participants