Module: NdrUi::Bootstrap::InlineErrorsAndWarnings
- Included in:
- NdrUi::BootstrapBuilder
- Defined in:
- app/builders/ndr_ui/bootstrap/inline_errors_and_warnings.rb
Overview
Allows us to display errors and warnings in a bootstrap-friendly way
Defined Under Namespace
Classes: HelpBlock
Class Method Summary collapse
Class Method Details
.add_inline_errors_and_warnings_to_field_helper(selector) ⇒ Object
21 22 23 24 25 26 |
# File 'app/builders/ndr_ui/bootstrap/inline_errors_and_warnings.rb', line 21 def self.add_inline_errors_and_warnings_to_field_helper(selector) define_method("#{selector}_with_inline_errors") do |method, *args, &block| html = send("#{selector}_without_inline_errors", method, *args, &block) return html + inline_errors_and_warnings(method) end end |
.included(base) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/builders/ndr_ui/bootstrap/inline_errors_and_warnings.rb', line 28 def self.included(base) excluded = [:label, :fields_for, :hidden_field] # Although highly unlikely, through the use of | in all_known_field_helpers), # uniq ensures we avoid a stack overflow (base.all_known_field_helpers - excluded).uniq.each do |selector| class_eval do add_inline_errors_and_warnings_to_field_helper(selector) end base.send(:alias_method, "#{selector}_without_inline_errors".to_sym, selector) base.send(:alias_method, selector, "#{selector}_with_inline_errors".to_sym) end end |