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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Thursday, February 7, 2013 9:37:09 AM UTC+8, Frank 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) > > 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 whatyou are doing and the relevant bit from schema.rb ? Fred> 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 > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Y9ohO7uOh5YJ. For more options, visit https://groups.google.com/groups/opt_out.
On 7 February 2013 01:37, Frank Kumro <frank-H1oavYrsupCe8kRwQpwjMg@public.gmane.org> 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> > 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 > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
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:> On 7 February 2013 01:37, Frank Kumro <frank-H1oavYrsupCe8kRwQpwjMg@public.gmane.org> 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 > >> >> 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 >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >-- Frank Kumro http://frankkumro.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.