Created
March 11, 2016 17:10
-
-
Save vinhnglx/a5ceefd6405be7f134dd to your computer and use it in GitHub Desktop.
Custom validation message in Rails - Override prefix
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
class User < ActiveRecord::Base | |
validates_uniqueness_of :email, message: 'has already taken' | |
end | |
# user = User.new(email: '[email protected]') | |
# user.save! => User has already taken. | |
# If you wanna change the error message to "Your fucking account has already taken" | |
# just edit one file config/locales/en.yml | |
en: | |
activerecord: | |
attributes: | |
user: | |
email: 'Your fucking account' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'Your fucking account' --> LOL