[Ruby] How to create a linked radio button by converting the enum to Japanese

less than 1 minute read

Thing you want to do

I want to express the following enum with radio buttons.

enum loadtype: {normal: 0, trail: 1, beach: 2, track: 3}

And I want the options to appear in Japanese.

About Japaneseization of # enum

It will be translated into Japanese according to the contents of this article. https://qiita.com/tanutanu/items/d44a92425188a4489ec6

Describe the radio button linked to the Japaneseized enum

Described as below in View Form

<%= f.collection_radio_buttons :loadtype, Post.loadtypes_i18n, :first, :last %>

The meaning of the code is as follows

<%= f.collection_radio_buttons [column name], [collection to be displayed], [value], [character string to be displayed in text] %>