Skip to content
This repository was archived by the owner on May 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/action_view/helpers/dynamic_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def error_messages_for(*params)
html[key] = 'error_explanation'
end
end
options[:object_name] ||= params.first
options[:object_name] ||= params.first.to_s.gsub('_', ' ')

I18n.with_options :locale => options[:locale], :scope => [:activerecord, :errors, :template] do |locale|
header_message = if options.include?(:header_message)
options[:header_message]
else
locale.t :header, :count => count, :model => options[:object_name].to_s.gsub('_', ' ')
locale.t :header, :count => count, :model => options[:object_name].to_s
end

message = options.include?(:message) ? options[:message] : locale.t(:body)
Expand Down
3 changes: 0 additions & 3 deletions test/dynamic_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ def test_error_messages_for_many_objects
# any default works too
assert_dom_equal %(<div class="error_explanation" id="error_explanation"><h2>2 errors prohibited this monkey from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "monkey")

# should space object name
assert_dom_equal %(<div class="error_explanation" id="error_explanation"><h2>2 errors prohibited this chunky bacon from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :object_name => "chunky_bacon")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing a test instead of adding one ?

# hide header and explanation messages with nil or empty string
assert_dom_equal %(<div class="error_explanation" id="error_explanation"><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>), error_messages_for(:user, :post, :header_message => nil, :message => "")

Expand Down