title: Rails - ActionView::Base.field_error_proc moving up the DOM tree?
body: <p>Is there anyway to go up the DOM tree from the html_tag element passed in?</p>
  
  <pre><code>ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
    # implementation
  end
  </code></pre>
  
  <p>Is there anyway I can implement this method to move up the DOM tree and place a class on the parent div?</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;div class="email"&gt;
    &lt;label for="user_email"&gt;Email Address&lt;/label&gt;
    &lt;input id="user_email" name="user[email]" size="30" type="text" value=""&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I would like to place a class on the div.email rather than place something directly on the input/label.</p>
  
  <p>Can this be done with the field_error_proc method or is there a clean alternative?</p>
  
  <p>I want to avoid doing this explicitly in my views on every form field. (like the following)</p>
  
  <pre><code>.email{:class =&gt; object.errors[:email].present? 'foo' : nil}
    =form.label :email
    =form.text_field :email
  </code></pre>
  
  <p>FYI: Short answer to my question is that there is no way to gain access to additional portions of the DOM in the field_error_proc method. This is due to the fact that these methods are not actually building a DOM but instead just concatting a bunch of strings together. For info on some possible work arounds, read the solutions below.</p>