This project is archived and is in readonly mode.
Ruby rss stdlib conflict with Time#to_s(:format)
-
Geoff Buesing
Huh, that's weird -- you're getting a 1 for 0 args error on #to_s, which makes me think a nil got in there, or some other class that doesn't accept a :format param for #to_s. But I can't figure out how that would have happened.
What was your work-around?
-
Ariejan de Vroom
# item.pubDate reports to be of type Time. Time.parse(item.pubDate.to_s) works fine. # Using item.pubDate directly (as shown) this results in the exception seen in trace.txt # when saving. # When replacing 'item.pubDate' with 'Time.parse(item.pubDate.to_s)' things work fine (as expected) :published_at => item.pubDate,item.pubDate comes from parsing an RSS feed with SimpleRSS.parse. It reports to of type Time. The work-around is to convert the pubDate to string and parse it again.
-
Ariejan de Vroom
Also see http://gist.github.com/43755 for the full code.
-
Geoff Buesing
Ok I did a quick test, it appears that a pubDate returned from the Ruby stdlib RSS parser is a class of Time, but the arity of its to_s method is 0, even if you load ActiveSupport, which alias_method_chains behavior on #to_s to allow you to pass in a format param. Hence, the "ArgumentError: wrong number of arguments (1 for 0)"
Other time objects respond as expected -- Time.now.to_s(:db) will work fine. So, the RSS library isn't overriding ActiveSupport globally, it appears to be limited the case of datetimes it parses from XML.
I took a look at the Ruby RSS parsing code, but I can't easily figure out what's going on there. Dunno if there's anything we can really do about this.
-
Geoff Buesing
- State changed from new to open
- Title changed from ArgumentError in time_with_zone.rb:146 to Ruby rss stdlib conflict with Time#to_s(:format)
A fix for this would be nice.
-
Santiago Pastorino
- Tag changed from 2.2-stable, 2.2.2, time, timewithzone to 22-stable, 222, time, timewithzone
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale