Skip to content

Instantly share code, notes, and snippets.

View aberranthacker's full-sized avatar
👾

Oleg Tsymbalyuk aberranthacker

👾
  • Moscow
  • 21:38 (UTC +03:00)
View GitHub Profile
@aberranthacker
aberranthacker / bootstrap_form_builder.rb
Created August 25, 2016 13:02 — forked from cbmeeks/bootstrap_form_builder.rb
Twitter Bootstrap Form Builder
class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
delegate :capture, :content_tag, :tag, to: :@template
%w[text_field text_area password_field collection_select].each do |method_name|
define_method(method_name) do |name, *args|
errors = object.errors[name].any?? " error" : ""
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : ""
content_tag :div, class: "clearfix#{errors}" do