我有这个数组:
address_types = ["main", "invoice", "work"]
我想将这个数组转换为:
[
["#{t('activerecord.attributes.address.address_type.main')}", "main"],
["#{t('activerecord.attributes.address.address_type.invoice')}", "invoice"],
["#{t('activerecord.attributes.address.address_type.work')}", "work"]
]
我怎样才能做到这一点?
答案 0 :(得分:1)
address_types.map do |entry|
[t("activerecord.attributes.address.address_type.#{entry}"), entry]
end