-1

我有这行代码:

<%= select "family", "num_of_children", (1..10), { :include_blank => true } %>

我想在列表末尾添加一项。在这种情况下:我想要一个“更多”选项作为最后一项。我怎样才能做到这一点?

4

2 回答 2

2

将范围转换为数组,然后附加'more'到它:

<%= select "family", "num_of_children", (1..10).to_a << 'more', { :include_blank => true } %>
于 2013-06-13T14:59:25.140 回答
1
<%= select "family", "num_of_children", (1..10).to_a + [['more', '11']], { :include_blank => true } %>
于 2013-06-13T14:53:27.653 回答