diff --git a/lib/action_view/helpers/dynamic_form.rb b/lib/action_view/helpers/dynamic_form.rb index f22bbc6..b74ff65 100644 --- a/lib/action_view/helpers/dynamic_form.rb +++ b/lib/action_view/helpers/dynamic_form.rb @@ -87,6 +87,10 @@ def form(record_name, options = {}) contents.safe_concat('') end + def convert_to_model(object) + object.respond_to?(:to_model) ? object.to_model : object + end + # Returns a string containing the error message attached to the +method+ on the +object+ if one exists. # This error message is wrapped in a DIV tag by default or with :html_tag if specified, # which can be extended to include a :prepend_text and/or :append_text (to properly explain diff --git a/test/dynamic_form_test.rb b/test/dynamic_form_test.rb index d0bb7cc..23c7e36 100644 --- a/test/dynamic_form_test.rb +++ b/test/dynamic_form_test.rb @@ -122,8 +122,6 @@ def setup super setup_post setup_user - - @response = ActionController::TestResponse.new end def url_for(options) @@ -370,7 +368,7 @@ def test_default_form_builder_no_instance_variable assert_dom_equal expected, output_buffer end - + def test_error_messages_without_prefixed_attribute_name error = error_messages_for(@post) assert_dom_equal %(

1 error prohibited this post from being saved

There were problems with the following fields:

),