Question: Question:
I don't know how to change the model name of the error message displayed when the value is invalid in form to Japanese.
class Ranking < ActiveRecord::Base
has_many :ranking_posts, dependent: :destroy
accepts_nested_attributes_for :ranking_posts
validates_associated :ranking_posts
end
When
class RankingPost < ActiveRecord::Base
belongs_to :ranking
default_scope -> { order('rank DESC') }
validates :title, :description, :rank, presence: true
end
As a result, I created a form that can update Ranking and Ranking Post at the same time. And if you send a form with an invalid value on the Ranking Post side, the error message "Ranking posts is an invalid value." Is displayed. I would like to know how to translate this "Ranking posts" into Japanese.
with i18n
ja:
activerecord:
models:
ranking/ranking_posts: すべてのランキング記事
But it didn't apply. I would like to know how the nested model name can be translated into Japanese.
Answer: Answer:
Since it is the name of the ranking_posts
attribute of the ranking
model, I think it is better to write the setting under activerecord.models
instead of activerecord.attributes
. It looks like the following.
ja:
activerecord:
attributes:
ranking:
ranking_posts: すべてのランキング記事
It is around 4.6 of http://railsguides.jp/i18n.html .