-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I'd like a way to set a field to it's default value. I've found the #apply_default method but it doesn't seem to be designed for this purpose. Specifically:
1. It doesn't work on a field after it's been set
2. It doesn't consider aliased fields
What do you suggest?
Here's the current:
def apply_default(name) unless attributes.has_key?(name) if field = fields[name] default = field.eval_default(self) unless default.nil? || field.lazy? attribute_will_change!(name) attributes[name] = default end end end end