Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Ruby rss stdlib conflict with Time#to_s(:format)

#1701

As described in the following gist: http://gist.github.com/43755

When creating and saving a new instance of Article, an exception occurs in activesupport-2.2.2/lib/active_support/time_with_zone.rb:146

I've already found a solution/work-around to the problem, but there may be more to it.

As requested by manfred-s on #rails-contrib I report the issue here as well for further investigation.

Rails 2.2.2 was used when this error occured.

Reported by Ariejan de Vroom · January 6th, 2009 @ 11:16 AM

State: stale
Milestone: 3.x
Assigned to: Geoff Buesing Geoff Buesing
Importance: none

Activity

  1. Geoff Buesing
    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?

    January 7th, 2009 @ 06:17 AM

  2. Ariejan de Vroom
    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.

    January 7th, 2009 @ 10:25 AM

  3. Ariejan de Vroom
  4. Geoff Buesing
    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.

    January 7th, 2009 @ 03:08 PM

  5. Geoff Buesing
    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.

    February 8th, 2009 @ 07:19 PM

  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  7. Santiago Pastorino
    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.

    February 2nd, 2011 @ 05:03 PM

  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 05:03 PM