前提・実現したいこと
現在fields_forでネストした子モデルに保存するといった実装をしているのですが、子モデルのバリデーションに引っかかったときに出るバリデーションエラーのカラム名をja.ymlにて日本語にできず困っています。
子モデル: price
カラム名: service, price
バリデーション
validates :service, :price, presence: true
バリデーション時のエラー文
Prices serviceを入力してください
Prices priceを入力してください
自分で調べたことや試したこと
ja.ymlにて以下のように試しましたができませんでした。
ja: activerecord: attributes: person: name: 名前 gender: 性別 contact: 連絡先 sample: サンプル comment: コメント price/service: サービス名 price/price: 値段 price_service: サービス名 price_service: 値段
#priceモデル class Price < ApplicationRecord belongs_to :person, optional: true validates :service, :price, presence: true validates :service, length: { maximum: 30 } end #personモデル class Person < ApplicationRecord has_many :prices, dependent: :destroy accepts_nested_attributes_for :prices, allow_destroy: true validates :name, :gender, :contact, :sample, :comment, presence: true end
回答2件
あなたの回答
tips
プレビュー