Skip to content

Instantly share code, notes, and snippets.

@AquaGeek
Created May 14, 2011 02:36
Show Gist options
  • Select an option

  • Save AquaGeek/971852 to your computer and use it in GitHub Desktop.

Select an option

Save AquaGeek/971852 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #6745
From 318b7c7bad051fd6fdb72f24f4180a1b87b27844 Mon Sep 17 00:00:00 2001
From: Josh Sharpe <[email protected]>
Date: Mon, 25 Apr 2011 23:17:13 -0400
Subject: [PATCH] ActiveModel::Errors#full_messages shouldn't generate an error message w/ an associations class name in it
---
activemodel/lib/active_model/errors.rb | 2 +-
.../test/cases/autosave_association_test.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 22ca3ef..362468c 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -254,7 +254,7 @@ module ActiveModel
if attribute == :base
message
else
- attr_name = attribute.to_s.gsub('.', '_').humanize
+ attr_name = attribute.to_s.split('.').last.humanize
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
I18n.t(:"errors.format", {
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 8f55b7e..f4b5b37 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -1154,7 +1154,7 @@ module AutosaveAssociationOnACollectionAssociationTests
assert [email protected]?
assert_equal ["cannot be blank"], @pirate.errors["#{@association_name}.name"]
- assert_equal ["#{@association_name.to_s.titleize} name cannot be blank"], @pirate.errors.full_messages
+ assert_equal ["Name cannot be blank"], @pirate.errors.full_messages
assert @pirate.errors[@association_name].empty?
ensure
I18n.backend = I18n::Backend::Simple.new
--
1.7.4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment