Module: FormHelper::ErrorMessages
- Defined in:
- lib/form_helper/error_messages.rb,
lib/form_helper/error_messages/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
Instance Method Details
#error_messages(attr, opts = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/form_helper/error_messages.rb', line 3 def (attr, opts={}) tag = opts[:tag] || :div class_name = opts[:class] || 'invalid' errors = @object.errors errors[attr].map{|| = errors.(attr, ) if block_given? yield else @template.content_tag(tag, ERB::Util.html_escape(), class: class_name) end }.join("\n").html_safe end |