Module: FormHelper

Defined in:
app/helpers/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#errors_for(document) ⇒ Object


3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/form_helper.rb', line 3

def errors_for(document)
  return unless document.errors.any?

  (:div, :class => 'error-messages') do
    body  = (:h2, 'Dang. The following errors are keeping this from being a success.')
    body += (:ul) do
      document.errors.full_messages.inject('') {|errs, msg| errs += (:li, h(msg)) }.html_safe
    end
  end
end

#label_for_attr(builder, field) ⇒ Object


14
15
16
# File 'app/helpers/form_helper.rb', line 14

def label_for_attr(builder, field)
  (builder.object_name + field).gsub(/[\[\]]/,'_').squeeze('_')
end