# Date.new exception in controller

**URL:** <https://www.ruby-forum.com/t/date-new-exception-in-controller/93085>\
**Category:** Rails\
**Created:** [April 27, 2007, 10:18am UTC](https://www.ruby-forum.com/t/date-new-exception-in-controller/93085 "2007-04-27T10:18:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven\_ASSchmidt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dc4da7/32.png) [@Sven\_ASSchmidt](https://www.ruby-forum.com/u/Sven_ASSchmidt)\
**Post date:** [April 27, 2007, 10:18am UTC](https://www.ruby-forum.com/t/date-new-exception-in-controller/93085/1 "2007-04-27T10:18:27Z")

</div>

Hi all,

I’m fairly new to rails and probably doing something stupid here.  
Unfortunately, I can’t come up with a good search term to help solve  
the problem – I hope someone here can help 🙂

I’m getting an “invalid date” exception when I call, say,

t1 = Date.new( 2007, 4, 27 )

in my controller class. I’m puzzled by this, because both in irb but  
also in script/console (same project) this works fine. I’ve tried  
Date.parse, Date.civil – they all lead to the same error (because  
they ultimately call the same problematic method).

Does anyone know why this doesn’t work in the controller? I’m using  
Locomotive 2.0.8 on OSX, which corresponds to ruby 1.8.6 and rails  
1.2.3. The “invalid date” exception is raised in “new!” at

lib/ruby/1.8/date.rb:727:in `new!' lib/ruby/1.8/date.rb:729:in`new’

Looking at the code in date.rb doesn’t ring any bells, either. One  
thing I noted was that during my attempts to solve this problem I also  
got

lib/ruby/1.8/date.rb:727:in `new!' lib/ruby/1.8/Date.rb:729:in`new’

at some point. Note the capital ‘D’. Now, this might be significant,  
because HFS+, the OSX file system, is case-insensitive (but case-  
preserving). Could there be a problem with file name clashes or is  
this merely cosmetic?

Any input greatly appreciated,  
Sven
