On 12/17/07, Olly Lylo <olly-2iX6Wuy7WY21Qrn1Bg8BZw@public.gmane.org>
wrote:>
> 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?
Wow, someone using sentry? First plugin I ever wrote :)
Um, try :allow_nil => true so it only validates #account_number if
it''s set. I wouldn''t bother with validates_presence_of
though.
--
Rick Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---