Roo Date object and ActiveRecord

36 views
Skip to first unread message

Frank Kumro

unread,
Feb 4, 2013, 7:58:44 PM2/4/13
to ruby...@googlegroups.com
Hi,

I am using Roo to read in an excel file (.xls) and having some issues with dates. ActiveRecord is being used to try to insert data into a postgres 9.2 database. The date column in the excel sheet is a Date type and the objects I am receiving from Roo are Date (verified by using *.class.name). However there is a certain date (01/10/02) that I am unable to insert due to a type casting error.

If anyone has run into this before or has any ideas please let me know.

Thanks!

-Frank

/home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/connection_adapters/column.rb:178:in `value_to_integer': undefined method `to_i' for Sun, 09 Apr 744389:Date (NoMethodError)
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/connection_adapters/column.rb:78:in `type_cast'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_methods/dirty.rb:86:in `_field_changed?'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_methods/dirty.rb:63:in `write_attribute'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_methods/write.rb:14:in `enterprise_value='
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in `each'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
  from /home/fkumro/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.11/lib/active_record/base.rb:497:in `initialize'
  from ruby_import.rb:68:in `new'
  from ruby_import.rb:68:in `process_parent'
  from ruby_import.rb:33:in `block in process'
  from ruby_import.rb:28:in `upto'
  from ruby_import.rb:28:in `process'
  from ruby_import.rb:171:in `<main>'
Reply all
Reply to author
Forward
0 new messages