I have a Feature model, where I am adding a before_save:
before_save {|feature|
downcase_value(feature)
}
def downcase_value(record)
record.value.downcase!
end
This works fine, unless I have saved a date in the column, in which case i get an error:
undefined method `downcase!' for Tue, 06 Feb 1996:Date
So my question is this – how can I test if the value can be downcased most efficiently?
You can replace downcase_value method body with:
but if you want to save any value, just modify your code this way: