Created
May 24, 2019 00:06
-
-
Save hamajyotan/48ccb972e7cbfd2d67e04488bf3c70b5 to your computer and use it in GitHub Desktop.
activerecord validation error i18n
This file contains 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
# app/models/hoge.rb | |
class Hoge < ApplicationRecord | |
validates :foo, presence: true | |
validates :bar, presence: true | |
validates :foo, uniqueness: { scope: [:bar] } | |
end |
This file contains 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
# config/locales/ja.yml | |
--- | |
ja: | |
activerecord: | |
errors: | |
models: | |
hoge: | |
attributes: | |
foo: | |
taken: "foo と bar で一意でないとあかんねん" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment