Error fields with a Hpricot twist
The default Rails behaviour for highlighting form fields with errors is to wrap them in a div, so:
<div>
<%= f.label(:email) %>
<%= f.text_field(:email, :size => '30') %>
</div>
Becomes:
<div>
<div class="fieldWithErrors"><label for="user_email">Email</label></div>
<div class="fieldWithErrors"><input id="user_email" name="user[email]" size="30" type="text" value="" /></div>
</div>
This is great when knocking together a quick prototype but as your site evolves you’ll probably want to customise it. This can be done very easily by using ActionView::Base.field_error_proc, assign a Proc to it either in your environment.rb or, if you’re a modern thinker, in an initializer and you’re good to go.

