From: Tom Willis Date: 2005-03-22T08:56:47+09:00 Subject: Noob: DateTime /DBI/ActiveRecord possible error...who knows OK, I feel I've done the due dilligence (googledilligence) and I can not figure this out. I'm using ActiveRecord to hit mysql. ddl: the tables relevant parts in question... ================================ # Table: 'transactions' CREATE TABLE `pf_transactions` ( #... `entry_date` datetime NOT NULL, `tran_date` datetime NOT NULL, #... ) TYPE=InnoDB; The unit test code... ====================== entry_date = DateTime.new(2005,4,1) tran_date = DateTime.new(2005,4,1) tran = PFTransaction.new("entry_date"=>entry_date,"tran_date"=>tran_date) tran.save assert_not_nil tran.id #works t2 = PFTransaction.find(tran.id) #works assert_not_nil t2 #works assert_equal t2.id,tran.id, "id" #works assert_equal t2.entry_date,tran.entry_date, "entry_date" #error assert_equal t2.tran_date,tran.tran_date,"tran_date" #error output ================================ Loaded suite test_transactions Started E Finished in 2.396059 seconds. 1) Error: test_transaction(TC_TestTransaction): NoMethodError: private method `gsub!' called for # /usr/lib/ruby/1.8/date/format.rb:253:in `_parse' /usr/lib/ruby/1.8/parsedate.rb:9:in `parsedate' /usr/local/lib/site_ruby/1.8/active_record/connection_adapters/abstract_adapter.rb:216:in `string_to_time' /usr/local/lib/site_ruby/1.8/active_record/connection_adapters/abstract_adapter.rb:184:in `type_cast' /usr/local/lib/site_ruby/1.8/active_record/base.rb:1151:in `read_attribute' /usr/local/lib/site_ruby/1.8/active_record/base.rb:1128:in `method_missing' test_transactions.rb:65:in `test_transaction' 1 tests, 3 assertions, 0 failures, 1 errors So I guess my question is, is there a trick to getting DateTime values into out of Mysql through ruby dbi, and active_record? I didn't get any hits that indicated this was a known bug and there was a workaround, so I'm assuming I'm doing something incorrectly. Here's to hoping. -- Thomas G. Willis http://paperbackmusic.net