diff --git a/lib/simple_form.rb b/lib/simple_form.rb index 76e85919..70576d4b 100644 --- a/lib/simple_form.rb +++ b/lib/simple_form.rb @@ -6,7 +6,6 @@ module SimpleForm autoload :Components, 'simple_form/components' autoload :ErrorNotification, 'simple_form/error_notification' autoload :FormBuilder, 'simple_form/form_builder' - autoload :HasErrors, 'simple_form/has_errors' autoload :Helpers, 'simple_form/helpers' autoload :I18nCache, 'simple_form/i18n_cache' autoload :Inputs, 'simple_form/inputs' diff --git a/lib/simple_form/components/errors.rb b/lib/simple_form/components/errors.rb index 93ce710f..8b462ba8 100644 --- a/lib/simple_form/components/errors.rb +++ b/lib/simple_form/components/errors.rb @@ -1,7 +1,7 @@ module SimpleForm module Components module Errors - include SimpleForm::HasErrors + include SimpleForm::Helpers::HasErrors def error template.content_tag(error_tag, error_text, error_html_options) if has_errors? diff --git a/lib/simple_form/error_notification.rb b/lib/simple_form/error_notification.rb index 12a34cd4..154bbf6a 100644 --- a/lib/simple_form/error_notification.rb +++ b/lib/simple_form/error_notification.rb @@ -1,7 +1,7 @@ module SimpleForm class ErrorNotification delegate :object, :object_name, :template, :to => :@builder - include SimpleForm::HasErrors + include SimpleForm::Helpers::HasErrors def initialize(builder, options) @builder = builder diff --git a/lib/simple_form/has_errors.rb b/lib/simple_form/has_errors.rb deleted file mode 100644 index 9693ab61..00000000 --- a/lib/simple_form/has_errors.rb +++ /dev/null @@ -1,14 +0,0 @@ -module SimpleForm - module HasErrors - - protected - - def errors - object.errors - end - - def has_errors? - object && object.respond_to?(:errors) && errors.present? - end - end -end diff --git a/lib/simple_form/helpers.rb b/lib/simple_form/helpers.rb index 9c98380a..53bbc91e 100644 --- a/lib/simple_form/helpers.rb +++ b/lib/simple_form/helpers.rb @@ -1,5 +1,6 @@ module SimpleForm module Helpers + autoload :HasErrors, 'simple_form/helpers/has_errors' autoload :Maxlength, 'simple_form/helpers/maxlength' autoload :Pattern, 'simple_form/helpers/pattern' autoload :Validators, 'simple_form/helpers/validators' diff --git a/lib/simple_form/helpers/has_errors.rb b/lib/simple_form/helpers/has_errors.rb new file mode 100644 index 00000000..385c1ea7 --- /dev/null +++ b/lib/simple_form/helpers/has_errors.rb @@ -0,0 +1,15 @@ +module SimpleForm + module Helpers + module HasErrors + private + + def errors + object.errors + end + + def has_errors? + object && object.respond_to?(:errors) && errors.present? + end + end + end +end \ No newline at end of file