From: Ezra Zygmuntowicz Date: 2007-07-28T05:55:22+09:00 Subject: Re: Facets error while using Time.parse On Jul 27, 2007, at 12:34 PM, Trans wrote: > > > On Jul 27, 10:40 am, "mer...@gmail.com" wrote: >> I have install latest facets using gem. I am having this issue with >> Time.parse with facets. Any ideas? >> >> [spatel@taamserver ~]$ ruby --version >> ruby 1.8.6 (2007-06-07 patchlevel 36) [i686-linux] >> >> Everything is fine here: >> >> [spatel@taamserver ~]$ cat x1.rb >> #require 'facets' >> p Time.parse("3:40:40") >> p Time.parse('4:41:41') >> p Time.parse('5:42:42') >> [spatel@taamserver ~]$ ruby x1.rb >> Fri Jul 27 03:40:40 -0500 2007 >> Fri Jul 27 04:41:41 -0500 2007 >> Fri Jul 27 05:42:42 -0500 2007 >> >> Same program with first line uncommented >> >> [spatel@taamserver ~]$ cat x1.rb >> require 'facets' >> p Time.parse("3:40:40") >> p Time.parse('4:41:41') >> p Time.parse('5:42:42') >> [spatel@taamserver ~]$ ruby x1.rb >> Fri Jul 27 03:40:40 -0500 2007 >> Fri Jul 27 13:24:55 -0500 2007 >> Fri Jul 27 13:24:55 -0500 2007 > > Want to see the culprit? Would you believe I tracked it to this: > > class Symbol > # Same functionality as before, just a touch more efficient. > > def to_s > @to_s || (@to_s = id2name) > end > end > > I'm not sure how exactly that could break anything. But somehow it > does. Anyone? > > A quick fix, remark out the line in lib/facets.rb (in facets' gem > dir): > > #require 'facets/core/symbol/to_s' > > T. Trans- I ran into this same thing, I had defined the same Symbol#to_s in merb. ActifveRecord was dropping created_at and updated_at attributes after the first time you would access them. Turns out it was some code deep in the Date stdlib that does some weird concatenating of symbols that was not compatible with Symbol#to_s as you have it defined. I had to remove it from my library because it caused very hard to track down bugs. Cheers- -- Ezra Zygmuntowicz -- Founder & Ruby Hacker -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)