problem: within the DB there is a special "empty" string, this string
must never be changed.
how to best enforce this rule?
Currently I have....
******************************************************************
# override the string_value setter,
# to control empty string from ever being overwritten
# ensure that the single empty string is never modified
def string_value=(sv)
if self[:string_value].blank? && !self.new_record?
raise "Empty String May Not Be Modified"
#errors.add(:string_value, "Empty String May Not Be Modified")
else
self[:string_value] = sv
end
end
******************************************************************
looking for better / more elegant ideas
thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
> problem: within the DB there is a special "empty" string, this string > must never be changed. > > how to best enforce this rule?http://agilewebdevelopment.com/plugins/attrlocked Or something similar to that maybe...> > Currently I have.... > > ****************************************************************** > # override the string_value setter, > # to control empty string from ever being overwritten > # ensure that the single empty string is never modified > def string_value=(sv) > if self[:string_value].blank? && !self.new_record? > raise "Empty String May Not Be Modified"#errors.add(:string_value, "Empty String May Not Be Modified")> else > self[:string_value] = sv > end > end > ****************************************************************** > > looking for better / more elegant ideas > > thanks in advance > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---