I don't know if this could help but I had kind of a similar problem at
one point. After much research I ended up coming across a solution by
which you can modify in your model the value returned from the DB. You
have to override the reader method (code below). This worked for me
only when reading values from the table as I had no problem inserting
values in it and never inserted a null or empty value but I guess the
same could be done with the writer method (dob= in this case):

class MyOracleTable < ActiveRecord::Base
  def dob
    self[:dob] or '0001-01-01'.to_date
  end
end

Every time that a row is retrieved from the table and the value of DOB
is used the model will return the DOB if there is one or an
initialized date value. I chose to implement '0001-01-01' but it could
be anything you want (i.e.: Date.new).

I hope this helps.

On Sep 14, 11:03 am, rheenen <[email protected]> wrote:
> Hello all. I am a novice Ruby on Rails programmer, starting my first
> project using a legacy Oracle 10 database. Using 'reverse_scaffold' I
> have created the models/controllers/views for my existing Oracle
> tables.
>
> All seems to work well, using /model/index, /model/show for most of my
> tables, *except* when one of the tables contains a Oracle 'date'
> column, for example when going to ~/filelists/show/959:
>
> ActiveRecord::StatementInvalid in FilelistsController#show
> ArgumentError: invalid date: SELECT * FROM filelist WHERE
> (filelist.fllid = 959)
>
> I already tried updating the record with NULL values for the date
> columns, or with actual valid date values, but ActiveRecord *or*
> OracleEnhancedAdapter seems to refuse to load my date values.
>
> Is this a known issue or is there something else I should do in my
> model file to make date support work?
>
> Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to