Skip to content

Instantly share code, notes, and snippets.

@JonasNielsen
Created April 27, 2010 20:32
Show Gist options
  • Save JonasNielsen/381287 to your computer and use it in GitHub Desktop.
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
# 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