Error message in rails

Hi,
I used the below syntax in config/initializers, but i am getting
the error message two times, please suggest me the better way to over
come it

ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<(input|label|textarea|select)/
error_class = ‘error’
nodes = Hpricot(html_tag)
nodes.each_child { |node| node[:class] =
node.classes.push(error_class).join(’ ') unless !node.elem? ||
node[:type] == ‘hidden’ || node.classes.include?(error_class) }
nodes.to_html
else
html_tag
end
end