Studying “Agile Web D.” I stumbled over the validation method
for a database field in the data model. The (german) error message
should contain diacritical characters which have to be html-escaped. I
tried this:
errors.add( :price, h(" muss grösser 0 sein" )) if ((price.nil?) ||
(price < 0.01))
which leads to the error message
undefined method `h’
Two questions:
- How do I get the function h to work in the database model?
- Is this the correct place to do it? Wouldn’t the formatting of the
error message rather have to be located in a view?