Rails related Ruby question

A simple and clean way (and also the preffered way of doing this) is by a Rails plugin.

Create a folder under vendor/plugins, maybe "date_extensions", create an "init.rb" file. Your init.rb would look like this:

Date.class_eval do

  def is_older_than( other_date )     self < other_date   end

end

And so on, adding the other methods you want. For more about ruby method definition, read the metaprogramming chapter from -> http://oreilly.com/catalog/9780596516178/toc.html

Maurício Linhares wrote:

A simple and clean way (and also the preffered way of doing this) is by a Rails plugin.

Create a folder under vendor/plugins, maybe "date_extensions", create

...

Maur�cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)

Thanks Mauricio, I had no idea it was that simple to make a plugin!

thanks, jp