I have an issue where I'm trying to do some validation, but part of
the validation calculation is based on a value that I want to set
in a before_create filter. Unfortunately, before_create is called
*after* the validation callbacks, so my value isn't available at
validation time.
Specifically:
#-------------------------------------------------
validates_uniqueness_of :account_name,
:scope => :year
before_create :set_year
(etc etc etc...)
protected
def set_year
self.year = <whatever is appropriate>
end
#-------------------------------------------------
I want to allow account names to repeat, but not within years.
Is there a clean way to get this behavior without having to mess
with the constructor? Messing with the constructor just for this
when it's called so often in other situations seems ham-fisted.
Thanks much!
-glenn
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---