Trying to insert a date

I'm a Ruby on Rails and MySQL newbie, trying to get started with the
lynda.com training, so excuse my ignorance. Using Ruby 1.8.6, Rails
1.1.6, and mysql 14.12 Distrib 5.051b for Win32 on a Vista machine (not
using the current version of rails as the lynda.com training was using
1.1.6 and using the newest version, some of the examples weren't working
(scafolding for example).

I'm just starting to learn how to work with databases. I have a mysql
database up and running with an albums table, and have the following
code in my controller:

def create
    @album = Album.new
    @album.title = 'Aftermath'
    @album.artist = 'The Rolling Stones'
    @album.genre = 'Rock'
    @album.release_date = '1966-01-01 12:00:00'
    render(:action => 'show_album')
  end

I have had no problem reading from the database through other code, but
when I do this, and then look at the variables (in my render),
album.release_date shows up as null. If I change the input date to a
Time.now(), it works fine. (Before I had an @album.save and was getting
an error that the release_date was null (and can't be as defined in the
db).

Is there a reason why I can't insert the release_date of the album?

Thanks for the help, and again, forgive me if this should be obvious to
me.

Swizzle

def create
   @album = Album.new
   @album.title = 'Aftermath'
   @album.artist = 'The Rolling Stones'
   @album.genre = 'Rock'
   @album.release_date = '1966-01-01 12:00:00'
   render(:action => 'show_album')
end

I have had no problem reading from the database through other code,
but
when I do this, and then look at the variables (in my render),
album.release_date shows up as null. If I change the input date to a
Time.now(), it works fine. (Before I had an @album.save and was
getting
an error that the release_date was null (and can't be as defined in
the
db).

On some platforms Ruby's time object can't deal with dates < 1970. Is
this a factor here ?
Newer versions of rails cope with this (by using a DateTime object
when approproate) but 1.1.6 may well not.

Another point of interest is that http://weblog.rubyonrails.org/2007/3/14/rails-1-2-3-compatible-with-ruby-1-8-6-and-other-fixes
  says that rails 1.2.3 added compatibility with ruby 1.8.6 which
rather implies that older versions (such as 1.1.6) might exhibit some
quirks.

Fred

Frederick Cheung wrote:

Chris Bedo wrote:

Frederick Cheung wrote:

I have had no problem reading from the database through other code,
but
when I do this, and then look at the variables (in my render),
album.release_date shows up as null. If I change the input date to a
Time.now(), it works fine. (Before I had an @album.save and was
getting
an error that the release_date was null (and can't be as defined in
the
db).

On some platforms Ruby's time object can't deal with dates < 1970. Is
this a factor here ?
Newer versions of rails cope with this (by using a DateTime object
when approproate) but 1.1.6 may well not.

Another point of interest is that
http://weblog.rubyonrails.org/2007/3/14/rails-1-2-3-compatible-with-ruby-1-8-6-and-other-fixes
  says that rails 1.2.3 added compatibility with ruby 1.8.6 which
rather implies that older versions (such as 1.1.6) might exhibit some
quirks.

Fred

Since I am only copying what the lynda.com training video is doing (and
he is inserting dates before 1970, I don't believe that your first point
is an issue, but if I can't figure anything else out, I'll have to
assume that it could be a Rails compatibility issue with Ruby 1.8.6. I
guess I'll have to convert Rails to the newer version to try it out.

Whoops! I hadn't had my morning coffee yet when I read Fred's reply to
my problem stating that some "platforms" might have pre-1970 issues.
The lynda.com training video was run on a Mac-OS, while I'm running
Vista. I tried changing the date to 1971, and everything worked fine.

Thanks for your help Fred.

Chris