Module: E9Rails::Helpers::ResourceErrorMessages::HelperMethods
- Defined in:
- lib/e9_rails/helpers/resource_error_messages.rb
Instance Method Summary collapse
-
#resource_error_messages!(options = {}) ⇒ Object
Assumes the definition of
resource.
Instance Method Details
#resource_error_messages!(options = {}) ⇒ Object
Assumes the definition of resource. Also accepts it as an option passed to the method.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/e9_rails/helpers/resource_error_messages.rb', line 19 def ( = {}) object = [:resource] || resource if object.errors.empty? || ( (errors_on = .delete(:on)) && (errors_on & object.errors.keys).empty? ) return '' end errors = object.errors.map {|attribute, msg| msg }.flatten.map {|m| "<li>#{m}</li>"}.join("\n") " <div id=\"errorExplanation\">\n <ul>\#{errors}</ul>\n </div>\n HTML\nrescue => e\n ''\nend\n".html_safe |