diff --git a/lib/vault/encrypted_model.rb b/lib/vault/encrypted_model.rb index aea98b9f..c11e47d0 100644 --- a/lib/vault/encrypted_model.rb +++ b/lib/vault/encrypted_model.rb @@ -62,7 +62,7 @@ def vault_attribute(attribute_name, options = {}) serializer.define_singleton_method(:decode, &options[:decode]) end - attribute_type = options.fetch(:type, :value) + attribute_type = options.fetch(:type, :string) if attribute_type.is_a?(Symbol) constant_name = attribute_type.to_s.camelize diff --git a/spec/dummy/app/models/eager_person.rb b/spec/dummy/app/models/eager_person.rb index 2cb5b450..566ded28 100644 --- a/spec/dummy/app/models/eager_person.rb +++ b/spec/dummy/app/models/eager_person.rb @@ -15,6 +15,7 @@ class EagerPerson < ActiveRecord::Base key: "people_credit_cards" vault_attribute :details, + type: :value, serialize: :json vault_attribute :business_card, diff --git a/spec/dummy/app/models/lazy_person.rb b/spec/dummy/app/models/lazy_person.rb index 51c6f3b3..ca216c88 100644 --- a/spec/dummy/app/models/lazy_person.rb +++ b/spec/dummy/app/models/lazy_person.rb @@ -15,6 +15,7 @@ class LazyPerson < ActiveRecord::Base key: "people_credit_cards" vault_attribute :details, + type: :value, serialize: :json vault_attribute :business_card, diff --git a/spec/dummy/app/models/person.rb b/spec/dummy/app/models/person.rb index 1324df9b..498aefff 100644 --- a/spec/dummy/app/models/person.rb +++ b/spec/dummy/app/models/person.rb @@ -17,6 +17,7 @@ class Person < ActiveRecord::Base key: "people_credit_cards" vault_attribute :details, + type: :value, serialize: :json vault_attribute :business_card,