Is there an easy way to make error_message_on display more than just one error message? I know I could create a custom form builder, but it looks complicated and I would rather learn that when I have more time.
for anyone else who might come across this, i found field_error_proc. you can over ride it and have it automatically add the errors, you can leave the error_message_on out of your code completely. you just add this code to an initializer.
i combined it with the second example to also stop rails from putting those annoying divs around the fields with errors, it makes much more sense to simply add a css class to the fields.
http://snippets.dzone.com/posts/show/1671
ActionView::Base.field_error_proc = Proc.new {|html_tag, instance| if instance.error_message.kind_of?(Array) %(#{html_tag}<span class='validation-error'>←# {instance.error_message.join(',')}</span>) else %(#{html_tag}<span class='validation-error'>←# {instance.error_message}</span>) end }
http://thewebfellas.com/blog/2008/4/21/error-fields-with-a-hpricot-twist
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