Module: TwiceBaked::ApplicationHelper
- Defined in:
- app/helpers/twice_baked/application_helper.rb
Instance Method Summary collapse
- #tb_form_error_field(record, attribute) ⇒ Object
- #tb_form_error_header(record) ⇒ Object
- #tb_form_errors(record, *fields_to_display) ⇒ Object
- #tb_form_field(attribute) ⇒ Object
Instance Method Details
#tb_form_error_field(record, attribute) ⇒ Object
26 27 28 29 30 31 |
# File 'app/helpers/twice_baked/application_helper.rb', line 26 def tb_form_error_field(record, attribute) = record.errors[attribute].first if return content_tag :p, , :class => 'help-block form-field-error' end end |
#tb_form_error_header(record) ⇒ Object
19 20 21 22 23 24 |
# File 'app/helpers/twice_baked/application_helper.rb', line 19 def tb_form_error_header(record) if record.errors.any? = "Please correct the following #{'error'.pluralize(record.errors.size)}:" return content_tag :h4, , :class => 'form-field-error' end end |
#tb_form_errors(record, *fields_to_display) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/twice_baked/application_helper.rb', line 3 def tb_form_errors(record, *fields_to_display) if record.errors.any? content_tag :div, :class => 'form-errors' do concat(tb_form_error_header(record)) concat(raw "<ul>") if fields_to_display.any? = fields_to_display.collect{ |field| record.errors.(field) }.flatten() else = record.errors. end concat(raw .collect{ |msg| "<li>#{msg}</li>" }.join()) concat(raw "</ul>") end end end |
#tb_form_field(attribute) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/helpers/twice_baked/application_helper.rb', line 33 def tb_form_field(attribute) content_tag :div, :class => 'form-group' do concat label_tag attribute, attribute, :class => 'col-sm-2 control-label' concat(content_tag(:div, :class => 'col-sm-10') do text_field_tag attribute, :placeholder => attribute, :class => 'form-control' end) end end |