Created
April 27, 2010 20:32
-
-
Save JonasNielsen/381287 to your computer and use it in GitHub Desktop.
Altering error messages to only show the attribute name in the error message, if the error message starts with a lower-case character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this file with your initializers | |
# Altering error messages to only show the attribute name in the error message, | |
# if the error message starts with a lower-case character | |
if RAILS_GEM_VERSION =~ /^2\.3\.5/ | |
class ActiveRecord::Error | |
def full_message | |
if attribute.to_s == 'base' || message =~ /^[[:upper:]]/ | |
message | |
else | |
generate_full_message(default_options) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment