The best way to handle this is to have language independent values โโin the database and localized labels in the user interface. You can achieve this by changing the options for your choice as follows:
<%= select(:coffee, :size, Coffee::SIZES.collect {|d| [I18n.t(d), d]}) %>
and having this in your locale file:
some-language: small: "small-translation" medium: "medium-translation" big: "big-translation"
This will generate html as follows:
<select name="coffee[size]"> <option value="small">small-translation</option> <option value="medium">medium-translation</option> <option value="big">big-translation</option> </select>
The user will see the localized parameters in select, but locale-dependent values โโwill be published in requests, so your check will work as it should.
source share