【问题标题】:Decrescent range of year for select选择的年份递减范围
【发布时间】:2015-10-10 23:36:33
【问题描述】:

我有什么

options_for_select(1995..Date.today.year)

我想要的蛮力

options_for_select((1995..Date.today.year).to_a.reverse)

如何重写第二个options_for_select 而不必反转数组?

【问题讨论】:

    标签: ruby-on-rails ruby date datetime select


    【解决方案1】:

    您可以改用downto

    options_for_select(Date.today.year.downto(1995))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      • 2017-12-10
      相关资源
      最近更新 更多