This project is archived and is in readonly mode.

#1701 ✓stale
Ariejan de Vroom

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

Reported by Ariejan de Vroom | January 6th, 2009 @ 11:16 AM | in 3.x

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.

Comments and changes to this ticket

  • Geoff Buesing

    Geoff Buesing January 7th, 2009 @ 06:17 AM

    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

    Ariejan de Vroom January 7th, 2009 @ 10:25 AM

    
          # 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
  • Geoff Buesing

    Geoff Buesing January 7th, 2009 @ 03:08 PM

    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

    Geoff Buesing February 8th, 2009 @ 07:19 PM

    • 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.

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 05:03 PM

    • 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

    Santiago Pastorino February 2nd, 2011 @ 05:03 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages