Created
August 18, 2015 11:40
-
-
Save tatyshev/8cb58d4b47e3e5ada304 to your computer and use it in GitHub Desktop.
missing errors_for method for formBuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
class FormBuilder | |
include ActionView::Helpers::TagHelper | |
include ActionView::Context | |
def errors_for(object_name, options = {}) | |
return if (errors = object.errors[object_name]).empty? | |
options[:class] ||= 'form_input-errors' # default class | |
limit = options[:limit].to_i | |
errors = errors.first(limit) if limit > 0 | |
errors.map! { |e| content_tag(:li, e) } | |
content_tag(:ul, errors.join.html_safe, options).html_safe | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment