🖥

Rails: Make Active_Model table_for compatible with i18n

2019/04/16に公開

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

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion