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

Support ActiveRecord 5.2 #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seanabrahams
Copy link

I'm not happy with this solution as it feels like a hack, but the tests pass and it gets the ball rolling.

@surjay
Copy link

surjay commented Mar 28, 2019

Any timetable for 5.2 compatibility?

@aahmad
Copy link

aahmad commented Jun 14, 2019

Is it possible to get this merged in? We are on Rails 5.2.3, and had broken tests (totally unrelated to any encrypted columns). Using @seanabrahams patch here fixed all the issues for us. Thank you.

if ::ActiveRecord::VERSION::STRING >= "5.2"
# This is needed support attribute_was before a record has
# been saved
set_attribute_was(attr, __send__(attr)) if value != __send__(attr)
Copy link

Choose a reason for hiding this comment

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

Works well with ActiveRecord 5.2.
However, in ActiveRecord 6.0.0, private method set_attribute_was was removed. rails/rails@6b0a9de

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how we should proceed with a fix that only works in a single release. My first thought was to allow this to merge, and for Rails 6 we create a new major release. That will also give us the opportunity to finally deprecate some old code and potentially do some major cleanup of the test suite.

Any thoughts on how we can move forward? Is my suggestion the best course or are there better ideas?

Copy link

Choose a reason for hiding this comment

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

Just update the pull request with the code snippet bellow
#337 (comment)

@wadewinningham
Copy link

Will this ever merge?

@cleicar
Copy link

cleicar commented Feb 17, 2020

@seanabrahams any news about this getting merged? Thanks.

@cleicar cleicar mentioned this pull request Feb 18, 2020
@bronzdoc
Copy link

bronzdoc commented Feb 28, 2020

@saghaulor @shuber @sbfaulkner @billymonk Thanks so much for maintain attr_encrypted!

Please let us know how can we help to get this PR merged, thank you!

@picman
Copy link

picman commented Jul 14, 2020

For ActiveRecord > 6.0.0 is no more possible use set_attribute_was as mentioned earlier. I don't want to create another pull request if even this one hasn't been merged yet. The following change of the code should solve it for ActiveRecord > 6.0.0 (taken from ruby-acts-as-taggable-on project).

lib/attr_encrypted/adapters/active_record.rb line 86

#set_attribute_was(attr, __send__(attr)) if value != __send__(attr)
if ActiveRecord.version <= Gem::Version.new('5.3.0')
  set_attribute_was(attr, __send__(attr)) if value != __send__(attr)
else
  unless #{attr}_changed?
    @attributes[attr] = ActiveModel::Attribute.from_user(attr, __send__(attr), ActsAsTaggableOn::Taggable::TagListType.new)
  end
end

@sbfaulkner
Copy link
Member

please see #379

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.