Sha256: 49a118b605e3724a7eddb7bcf2ddb9de9cbf024308d14ae21ffe05a7fa8fb404
Contents?: true
Size: 798 Bytes
Versions: 3
Compression:
Stored size: 798 Bytes
Contents
# coding: utf-8 module ErrorMessageOn module ErrorMessageHelper def field_container(model, method, options = {}, &block) css_classes = options[:class].to_a if error_message_on(model, method).present? css_classes << 'withError' end content_tag('p', capture(&block), :class => css_classes.join(' '), :id => "#{model}_#{method}_field") end def error_message_on(object, method, options = {}) object = convert_to_model(object) obj = object.respond_to?(:errors) ? object : instance_variable_get("@#{object}") if obj && obj.errors[method].present? errors = obj.errors[method].map { |err| h(err) }.join('<br />').html_safe content_tag(:p, errors, :class => 'inline-errors') else '' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
error_message_on-0.0.12 | lib/error_message_on/helper.rb |
error_message_on-0.0.11 | lib/error_message_on/helper.rb |
error_message_on-0.0.1 | lib/error_message_on/helper.rb |