ActiveRecord date field, insert date object?

Hello,

I am newish to rails and I am having an issue with inserting a date. The
field is type date in schema.db (and the migration). When I instantiate
the model class (*.new()) I receive the following error.

/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)

Database is postgresql 9.2

The object is a Date object and I've tried using the object as the
parameter, also I've tried .to_s and have received the same error.

On the object if I call .class "Date" is the result. The error means
there is no to_i method on my object, Date. What object type should I be
using for the date that ActiveRecord will support?

I am using a Date object because that is what roo is returning dates as.
Roo is used for processing Excel data (for those who never used it).

Any help would be great!

Thanks,

Hello,

I am newish to rails and I am having an issue with inserting a date. The

field is type date in schema.db (and the migration). When I instantiate

the model class (*.new()) I receive the following error.

/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)

Database is postgresql 9.2

The object is a Date object and I’ve tried using the object as the

parameter, also I’ve tried .to_s and have received the same error.

On the object if I call .class “Date” is the result. The error means

there is no to_i method on my object, Date. What object type should I be

using for the date that ActiveRecord will support?

Dates should work fine. Perhaps you could show a code snippet showing what you are doing and the relevant bit from schema.rb ?

Fred

Hello,

I am newish to rails and I am having an issue with inserting a date. The
field is type date in schema.db (and the migration). When I instantiate
the model class (*.new()) I receive the following error.

/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)

Show us your code that is generating the error. If you follow the
stack trace you should find it.

Colin

Well I should have traced through the stack trace before sending my
email. After reading some of the ActiveRecord code along side the stack
trace I figured it out. Turns out Roo was incorrectly detecting the cell
type and giving me a Date object for a field that was an integer. Thus
the .to_i method did not exist.

Thanks for the responses, pushed me in the right direction.

-Frank