views:

18

answers:

1

So in rails, if any of the input is not valid, the page returns back to the input page and red errors will show up next to that input_text or textarea. For example, <% validates_presence_of :email %> It will say the error at the top, and the email input text turns into red.

However, when I separately made a valid checking statement in a model, for example, <% def valid_email? TMail::Address.parse(self.email) rescue errors.add("Please type in the correct email address.") end %> It will say the error at the top, but the input_text itself does not turn into red.

How can I manually set the input text to be turn into red??

+1  A: 

It should be:

self.errors.add(:email, "Please type in the correct email address.")
Yannis
thanks, that did it
Please, accept the answer then…
Yannis