Forum: Ruby on Rails Changing the way form fields with errors are displayed

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fresh M. (Guest)
on 2009-03-02 20:25
What file I must to edit?


7.1. Changing the way form fields with errors are displayed
http://guides.rubyonrails.org/activerecord_validat...

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
  if instance.error_message.kind_of?(Array)
    %(#{html_tag}<span class='validation-error'>&nbsp;
      #{instance.error_message.join(',')}</span>)
  else
    %(#{html_tag}<span class='validation-error'>&nbsp;
      #{instance.error_message}</span>)
  end
end
Maurício L. (Guest)
on 2009-03-02 20:27
(Received via mailing list)
You don't need to edit any files, create a file with this code and
place it under you app initilizers folder.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)



On Mon, Mar 2, 2009 at 3:25 PM, Fresh M.
This topic is locked and can not be replied to.