Reputation: 7043
I need to create a ul>li list of month names in rails from Jan to Dec.
<ul class="nav nav-tabs">
<li><a href="#">Jan</a></li>
<li><a href="#">Feb</a></li>
<li><a href="#">Mar</a></li>
...
</ul>
So I'm thinking of going through a simple 1..12 loop, but I can't seem to find what method actually gets me these names! Thanks
Upvotes: 0
Views: 225
Reputation: 6015
You can get month names in
Date::ABBR_MONTHNAMES.dup.slice(1,12)
assign them in array and loop through
EDIT
controller
months = Date::ABBR_MONTHNAMES.dup.slice(1,12)
view
<ul class="nav nav-tabs">
<% months.each do |month| %>
<li><a href="#"><%= month %></a></li>
<% end %>
</ul>
Upvotes: 2