解决方法
只要放入你想要的范围循环,并使用Date :: MONTHNAMES数组就这样
(date.year..laterdate.year).each do |y| mo_start = (date.year == y) ? date.month : 1 mo_end = (laterdate.year == y) ? laterdate.month : 12 (mo_start..mo_end).each do |m| puts Date::MONTHNAMES[m] end end