Beginner's question: how to format data model error messages

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:

  1. How do I get the function h to work in the database model?
  2. Is this the correct place to do it? Wouldn’t the formatting of the
    error message rather have to be located in a view?

Sascha Mantscheff wrote:

Two questions:

  1. How do I get the function h to work in the database model?

You shouldn’t want to, although I believe it’s possible.

  1. Is this the correct place to do it? Wouldn’t the formatting of the
    error message rather have to be located in a view?

Yes, in this case it’s best to leave the string formatted as a native
Ruby string and do the HTML-izing in your view/helpers.