I’m looking at using Sentry (http://sentry.rubyforge.org/) to encrypt
a number of sensitive fields in an ActiveRecord model. I’m
encrypting a field which is currently called account_number. Sentry
requires that the database field is renamed to crypted_account_number
whilst a virtual field on the model called ‘account_number’ is added,
which returns the unencrypted fields.
So far so good.
However, I have validates_presence_of and validates_format_of helpers
for this field (:account_number) and the view form containing this
field is currently using f.account_number. Obviously I’d really like
these helpers to just work even when using Sentry, but this (as far as
I can see) isn’t possible. I can change the validates_presence_of
helper to reference :crypted_account_number, but clearly this won’t
work for the format helper. Is the best solution here to implement a
bespoke validate method on my model which performs this validation, or
is there a better way which I’m not seeing?
Thanks in advance.