Sascha Mantscheff
2006-Oct-07 05:24 UTC
Beginner''s question: how to format data model error messages
Studying "Agile Web Development" 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
eden li
2006-Oct-07 09:30 UTC
Re: Beginner''s question: how to format data model error messages
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.> 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?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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---