in controller:
@date = Date.today
@months = []
(0..17).each do |m|
@months << [@date.prev_month(m).strftime("%b, %Y"), @date.prev_month(m)]
end
In ERB:
<%= select_tag "month_year", options_for_select(@months) %>
In Order to get next 6 months and next year months:
@date = Date.today
@months = []
(0..17).each do |m|
@months << [@date.next_month(m).strftime("%b %Y"), @date.next_month(m)]
end
No comments:
Post a Comment