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 encrypt_table for STI #117

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/crypt_keeper/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def search_by_plaintext(field, criteria)
# Public: Encrypt a table for the first time.
def encrypt_table!
enc = encryptor_klass.new(crypt_keeper_options)
tmp_table = Class.new(ActiveRecord::Base).tap { |c| c.table_name = self.table_name }

tmp_table = Class.new(ActiveRecord::Base).tap do |c|
c.table_name = self.table_name
c.inheritance_column = :type_disabled
Copy link
Owner

Choose a reason for hiding this comment

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

What is type_disabled?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jmazzi this is just a way to disable STI. You set it to a non-existant column and it will be disabled.

Copy link
Owner

Choose a reason for hiding this comment

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

@itspriddle an anti-feature, got it!

end

transaction do
tmp_table.find_each do |r|
Expand Down