我是红宝石的新手。我有一个来自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
相反,我得到一个错误说未定义的局部变量或方法
使用I18n.t('key')
或t('key')
检索语言环境文件中的值。尝试
<% t('sample_array').each do |item| %>
<p><%= item %></p>
<% end %>