Date.today throws Invalid Date error only within Rails

I have a weird problem. I have this code in a helper class to the
view:

    today=Date.today

and this throws an exception with the message "invalid date" and the
stack trace being:

/usr/local/lib/ruby/1.8/Date.rb:591:in `new0'
/usr/local/lib/ruby/1.8/date.rb:703:in `today'

Of course, this works outside Rails. Any suggestions why this happens
inside Rails?

I have been able to re-create this quite easily in both OS X and in windows. [I thought it could be something to do with incompatible ruby versions in OS X].

So, to reproduce this, all I have to do is this:

  • Create a new rails app

  • Create a dummy controller

  • Create a dummy index method which does this:

    def index
    @today=Date.today
    end

  • Create a dummy index.rhtml view which prints @today.

This works.

Now to break it, all I have to do is

  • add require “Date” [capital “D”, require “date” works correctly]

It fails immediately at the Date.today line with an invalid date error. Before it fails, it dumps the following in the cmd prompt where webrick is running:

c:/ruby/lib/ruby/1.8/Date.rb:238: warning: already initialized constant MONTHNAM
ES
c:/ruby/lib/ruby/1.8/Date.rb:243: warning: already initialized constant DAYNAMES

c:/ruby/lib/ruby/1.8/Date.rb:247: warning: already initialized constant ABBR_MON

THNAMES
c:/ruby/lib/ruby/1.8/Date.rb:250: warning: already initialized constant ABBR_DAY
NAMES
c:/ruby/lib/ruby/1.8/Date.rb:254: warning: already initialized constant ITALY
c:/ruby/lib/ruby/1.8/Date.rb:258: warning: already initialized constant ENGLAND

c:/ruby/lib/ruby/1.8/Date.rb:262: warning: already initialized constant JULIAN
c:/ruby/lib/ruby/1.8/Date.rb:266: warning: already initialized constant GREGORIA
N

In my real app, however, I do not do a require “Date” - so I have no clue what is happening :(.

Any ideas?