I haven’t had much cause to play with the Time module in Ruby until today. I have used Time.now quite a bit, but not too much more than that. However, today I had to find the last 6 months names to label a graph and in a short period of time I had come up with this:

months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
labels = []
0.upto(5) do |x|
  labels.unshift(months[Time.now.months_ago(x).month-1])
end

Which I think is pretty neat, especially remembering what a pain it was in Perl last time I had to do it……..

So Richard White caught up with me a couple of days ago through Technorati and we had a chat about the development of his Ajax Scaffolding as a Rails Plugin. We have agreed to work together on this (which is great) and develop the generator and the plugin in sync (As he also notes in his (kind) comments on the 3.1.3 release of the generator).

Hopefully the first release of the plugin should not to be too far away and will add a little functionality to the existing code.

Continue reading »