🖥
Rails: Make Active_Model table_for compatible with i18n
Pass model object by specifying i18n directly to table_for.
table_for humans, i18n: Human do column :name column :gender { |result| result.gender } end
In the model, you only need to include ActiveModel.
class Human include ActiveModel::Model end
Set up the locales file. (Because the description place is not under activerecord :)
ja: activemodel: attributes: human: name: 名前 gender: 性別
Original by
Rails: ActiveModel の table_for を i18nに対応させる
About
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-04-16
Discussion