Rails - return an array of months for a select tag

前端 未结 10 2554
谎友^
谎友^ 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条回答
  •  Happy的楠姐
    2021-02-07 10:16

    Here's a sexy way to get the months only if that's all you want:

    Date::MONTHNAMES.slice(1..-1).map(&:to_sym)
    

提交回复
热议问题