Skip to content

Instantly share code, notes, and snippets.

@tatyshev
Created August 18, 2015 11:40
Show Gist options
  • Save tatyshev/8cb58d4b47e3e5ada304 to your computer and use it in GitHub Desktop.
Save tatyshev/8cb58d4b47e3e5ada304 to your computer and use it in GitHub Desktop.
missing errors_for method for formBuilder
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