我有这行代码:
<%= select "family", "num_of_children", (1..10), { :include_blank => true } %>
我想在列表末尾添加一个项目。在这种情况下:我想要一个“更多”选项作为最后一项。 我怎么能这样做?
答案 0 :(得分:2)
将范围转换为数组,然后将'more'
追加到它:
<%= select "family", "num_of_children", (1..10).to_a << 'more', { :include_blank => true } %>
答案 1 :(得分:1)
<%= select "family", "num_of_children", (1..10).to_a + [['more', '11']], { :include_blank => true } %>