As it turns out (and after lots of research and unless I am crazy
already) the problem seems to be in the INSERT statement that is
generated. Here goes an example (edited with just some date and
datetime values):
If I try to run manually the INSERT statement generated by Rails I get
the ORA-01861 error but if I run it editing the dates or datetime
values in format 'DD-MON-YY' (e.g.: '01-JAN-11'), as a post I found
suggested, the record is written to the table. BTW, in case it helps
all fields in the table that would receive a date or datetime value
are of type DATE.
Did I miss something obvious and it's just me not knowing how to set
the date/datetime values or is this a known problem?
Apologies if i'm missing the point, but you should always deal with
actual Time/Date/DateTime ruby objects and let rails handle the
translation into the format required by the database.
So, if you do something like
@foo = Foo.create(:time => Time.now)
rails will translate Time.now into the appropriate format.
I should have added a comment to my prior post. I do use ruby objects
to generate/calculate the Time/Date/DateTime values. The INSERT
statement I mentioned in the original message I retrieved it from the
development.log file. As far as I know that is the real INSERT
statement that runs against the Oracle DB and as you can see the
values that were generated are not what Oracle is expecting (DD-MON-
YY), if you trust that other post that helped me find the problem.
I did some more investigation and found that there is an alternative
to Oracle's adapter made by Raimonds Simanovskis. He calls it
'enhanced' adapter (http://blog.rayapps.com/2008/05/13/activerecord-
oracle-enhanced-adapter/). Just curious about it I read what it was
about and decided to give it a try.
Check out the differences in the INSERT statements that both adapters
generate for date values out of ruby objects (no code changes). Again,
this is out of development.log:
Good idea. I'll do it, although if I remember well what I read
Raimonds Simanovskis mentioned that he offered himself to Oracle to
maintain the adapter and they declined, not showing much interest in
enhancing it, which makes me believe not much will change,
unfortunately.
Original Oracle adapter is not maintained anymore since Rails 2.0 when
it was taken out of Rails core.
Therefore always please use oracle_enhanced adapter (http://github.com/
rsim/oracle-enhanced) which I maintain to be compatible with latest
Rails releases and which we use in many production applications.