-
Notifications
You must be signed in to change notification settings - Fork 425
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
does not work when environment was started with empty database #226
Comments
i ran into the same issue when starting with an empty database and loading the schema with |
found a better hack ... # A hack to make attr_encrypted always behave the same even when loaded without a database being present.
# On load it checks if the column exists and then defined attr_accessors if they do not.
# Reproduce with:
# CI=1 RAILS_ENV=test TEST=test/some_test.rb rake db:drop db:create default
#
# https://github.com/attr-encrypted/attr_encrypted/issues/226
def attr_encrypted(column, *)
super
bad = [
:"encrypted_#{column}_iv",
:"encrypted_#{column}_iv=",
:"encrypted_#{column}",
:"encrypted_#{column}="
]
(instance_methods & bad).each { |m| undef_method m }
end |
FYI hacky migration to make this work when moving data from an unencrypted column to an encrypted column. |
I ran into this with rake db:schema:load_if_ruby db:structure:load_if_sql
rake environment db:seed |
I believe that #294 should fix this. Can someone please confirm? |
Just found this thread after some long hours debugging unrelated changes to our CI tooling that triggered a similar case; attr_encrypted properties were written to the models but not persisted to the DB. Upgrading from 3.0.3 to 3.1 resolved the issue for me. Thanks! |
Same as @oehlschl |
When an rails app is started with eager_load but not database, then attr_encrypted initializes with attr_accessors ... which is bad ... basically trying to be too smart ... maybe it should ask for what kind of setup you want and then verify/blow up when that does not match your columns ... see #212
In my test I now do this to make it behave normally ... seems kind of bad :D
see zendesk/samson#1176
/fyi @saghaulor
The text was updated successfully, but these errors were encountered: