2008-06-18

I couldn’t find a helper in the API to just display months if you’re storing them as numbers (1-12) so I made one.
Add this helper code to your application_helper.rb or other appropriate *_helper.rb file.

	def monthname(monthnumber)
		if monthnumber
			Date::MONTHNAMES[monthnumber]
		end
	end

Use it in your view like this:

< %=h monthname(item.month) %>

One Response to “Month name helper passing month number for Rails”

  1. Adrian Carr Says:

    Hey, Thanks for posting this. After an hour of Googling it and trying different things, I came across your post and had it working in five minutes. I really appreciate it.
    -Adrian

Leave a Reply


I've left the country and this site is just an archive! Check out my trip blog!