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, -- Frank Kumro
on 2013-02-07 16:17
on 2013-02-07 16:19
On Thursday, February 7, 2013 9:37:09 AM UTC+8, Frank wrote: > (NoMethodError) > Dates should work fine. Perhaps you could show a code snippet showing what you are doing and the relevant bit from schema.rb ? Fred
on 2013-02-07 16:20
On 7 February 2013 01:37, Frank Kumro <frank@frankkumro.com> wrote: > 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
on 2013-02-07 16:54
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 On 02/07/2013 10:19 AM, Colin Law wrote: > >> >> > -- Frank Kumro http://frankkumro.com
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.