如何打印区分大小写的数组

时间:2013-04-06 22:00:25

标签: ruby

我有一个数组,其中包含各种不同情况的字符串,如下所示:

WEBSITES = ["The Atlantic", "BBC", "CNN", "The Economist" ]

当我循环遍历此数组(特别是我的Rails表单中的select帮助程序)时,我得到了

"The atlantic", "Bbc", "Cnn", "The economist"

如何使用与数组中相同的格式打印它?

编辑:

这是我的文件(Rails)。

数组在我的模型中

class Survey < ActiveRecord::Base
  WEBSITES = ["The Atlantic", "BBC", "CNN", "The Economist"]
end

表格在这里

<%= form_for @survey do |f| %>
  <% Survey::WEBSITES.each_with_index do |site, index| %>
    <%= f.label site %>
    <%= f.select "answer_field_#{ index +1 }".to_sym %>
  <% end %>
<% end %>

1 个答案:

答案 0 :(得分:2)

试试这个:

<%= f.label site, "#{site}" %>