Rails form helper to display email fields and their validation errors
I would try this (naming needs improvement):

*_helper.rb:

  def field_wrapper(errors, &amp;block)
    css_classes = %w(form-group floating-label)
    css_classes &lt;&lt; 'has-error has-feedback' if errors.any?
    content_tag :div, class: css_classes, &amp;block
  end

  def error_label(form, errors)
    form.label errors.join(', ') if errors.any?
  end


*.html.erb:

 &lt;%= field_wrapper f.object.errors[:to] do %&gt;
      &lt;%= error_label f, f.object.errors[:to] %&gt;
      &lt;%= f.email_field :to, class: "form-control" %&gt;
      &lt;%= f.label :to %&gt;
   &lt;% end %&gt;