Mensajes de validación personalizados de Rails

I'm trying to set form validation with cyrillic alphabet but I get

We're sorry, but something went wrong.

Aquí está el código que uso

  validates_presence_of :user, :message => "кирилица"

Que esta mal aquí ?

preguntado el 30 de junio de 12 a las 19:06

what is the error message generated in log file? -

This should work with ruby 2.0 -

1 Respuestas

You forgot to tell ruby that your source file is in utf-8

Ruby 1.9 assumes your source files are US-ASCII encoded unless you provide an

# encoding: utf-8 

comment at the beginning of your source file

PS : I would suggest you to use i18n to store your validation messages. You can find info about the mechanism aquí, it will allow you to either change default messages or specific messages for a model.

Respondido el 30 de junio de 12 a las 19:06

That was the problem. But is there more elegant solution. I don't want to put this line at every file of project where utf8 encoding is used - jo3

I added a PS about a more elegant solution - sist.

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.