Forum: Ruby on Rails Bizzare Date, DateTime, date_select issues

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Scott H. (Guest)
on 2006-04-10 21:09
I've been banging my head against this wall for several hours, and it
hurts now so I'll stop and ask someone.

In one of my forms I had been using a statement to extract the current
year for use with some form field calculations.

  <% currentyear = DateTime.now.year %>

And then further down several date_selects like the following,

    <%= date_select "member", "last_medical_date", :id =>
"member_last_medical_date", :order => [:year, :month, :day], :start_year
=> (currentyear - 5), :end_year => currentyear %>
    <label for="member_last_medical_date">Date of Last Medical Exam
(YYYY/MM/DD)</label><br>

The first statement subsequently stopped working!  Now with that
statement I get a "ArgumentError" where the DateTime.now.year has raised
an "invalid date" error.

If I use,

  <% currentyear = Time.now.year %>

instead, then I can get past THAT error, but then the date_select
statement raises the "invalid date" error message.

Out of desperation I've even uninstalled Ruby and Rails, and reinstalled
it all again.  This is all latest version stuff...   Ruby v1.8.4, Rails
v1.1.2, RadRails v0.6.1, MySQL v5.0.11 all running on Win2kSP4.

Any ideas?
Scott
Scott H. (Guest)
on 2006-04-10 22:49
Ok update;

  Ruby isn't the problem, as I can run an independant script with a
number of different Date/Time operations in order to extract the current
year (including the ones that don't work in rails).

  I've set up a whole new Rails environment on one of my Gentoo Linux
servers, moved my project over to that, and pointed it at the existing
MySQL server.  That worked fine!  So something in the setup of my
environment under Win2k has got buggered (like I said, things were
working, then they stopped!).  Uninstalling and re-installing didn't
help, but having to use two machines for development is just not right.

Any thoughts on how to correct this?

Scott
This topic is locked and can not be replied to.