我对红宝石很陌生。我有来自config\locales\en.yml的数组
sample_array:
- list1
- list2
- list3
- list4我正在尝试使用do循环将其输出到erb
<% sample_array.each do |list| %>
<p><%= list %></p>
<% end %>我的预期结果:
list1
list2
list3
list4相反,我得到了一个错误,即未定义的局部变量或方法。
发布于 2019-03-21 11:57:56
区域设置文件中的值是用I18n.t('key')或t('key')检索的。试一试
<% t('sample_array').each do |item| %>
<p><%= item %></p>
<% end %>https://stackoverflow.com/questions/55279782
复制相似问题