Rails - return an array of months for a select tag

前端 未结 10 2525
谎友^
谎友^ 2021-02-07 10:02

I\'m in an app that is on Rails 2.3.8, and need to return an array of month names and numbers to be plugged into an options_for_select statement. What I\'ve got so far is kind

10条回答
  •  别那么骄傲
    2021-02-07 10:26

    Found this nifty way to shift off the first nil but return a new collection of months. You cannot use shift on it since that would try to modify the frozen variable.

    Date::MONTHNAMES.drop(1)
    

提交回复
热议问题