public
Rubygem
Description: Adds support for automatically encrypting ActiveRecord attributes
Homepage: http://www.pluginaweek.org
Clone URL: git://github.com/pluginaweek/encrypted_attributes.git
Add documentation on reading encrypted attributes
obrie (author)
Mon Jul 07 18:17:42 -0700 2008
commit  f30f8d4936b15bef1d0b3440ad82eb86e8145cac
tree    e2ec39c0e969781042cc32299f98ed9d0a7baa2f
parent  20629b6c8531dd2cb488dea927da858e7aa27aed
...
127
128
129
130
 
 
 
 
 
131
132
133
...
127
128
129
 
130
131
132
133
134
135
136
137
0
@@ -127,7 +127,11 @@ module PluginAWeek #:nodoc:
0
           value = read_attribute(to_attr_name)
0
           
0
           # Make sure we set the encryptor for equality comparison when reading
0
-          # from the database
0
+          # from the database. This should only be done if the value is *not*
0
+          # blank, is *not* encrypted, and hasn't changed since it was read from
0
+          # the database. The dirty checking is important when the encypted value
0
+          # is written to the same attribute as the unencrypted value (i.e. you
0
+          # don't want to encrypt when a new value has been set)
0
           unless value.blank? || value.encrypted? || attribute_changed?(to_attr_name)
0
             # Create the encryptor configured for this attribute
0
             value.encryptor = create_encryptor(encryptor_class, options, :read, value)

Comments