Skip to content

Commit

Permalink
Fix no method error with error_messages_on. Closes #6935 [nik.wakelin…
Browse files Browse the repository at this point in the history
… Koz]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5870 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
NZKoz committed Jan 7, 2007
1 parent b4282df commit 31fb0de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Fix no method error with error_messages_on. Closes #6935 [nik.wakelin Koz]

* Slight doc tweak to the ActionView::Helpers::PrototypeHelper#replace docs. Closes #6922 [Steven Bristol] * Slight doc tweak to the ActionView::Helpers::PrototypeHelper#replace docs. Closes #6922 [Steven Bristol]


* Slight doc tweak to #prepend_filter. Closes #6493 [Jeremy Voorhis] * Slight doc tweak to #prepend_filter. Closes #6493 [Jeremy Voorhis]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/active_record_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def form(record_name, options = {})
# <%= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" %> => # <%= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" %> =>
# <div class="inputError">Title simply can't be empty (or it won't work)</div> # <div class="inputError">Title simply can't be empty (or it won't work)</div>
def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError") def error_message_on(object, method, prepend_text = "", append_text = "", css_class = "formError")
if object = instance_variable_get("@#{object}") && errors = object.errors.on(method) if (obj = instance_variable_get("@#{object}")) && (errors = obj.errors.on(method))
content_tag("div", "#{prepend_text}#{errors.is_a?(Array) ? errors.first : errors}#{append_text}", :class => css_class) content_tag("div", "#{prepend_text}#{errors.is_a?(Array) ? errors.first : errors}#{append_text}", :class => css_class)
else else
'' ''
Expand Down
6 changes: 5 additions & 1 deletion actionpack/test/template/active_record_helper_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ def test_error_messages_for_handles_nil
def test_error_message_on_handles_nil def test_error_message_on_handles_nil
assert_equal "", error_message_on("notthere", "notthere") assert_equal "", error_message_on("notthere", "notthere")
end end


def test_error_message_on
assert error_message_on(:post, :author_name)
end

def test_error_messages_for_many_objects def test_error_messages_for_many_objects
assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li><li>User email can't be empty</li></ul></div>), error_messages_for("post", "user") assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li><li>User email can't be empty</li></ul></div>), error_messages_for("post", "user")


Expand Down

0 comments on commit 31fb0de

Please sign in to comment.