Forum: Ruby on Rails Problem with RSS feed from Rails Recipes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pat M. (Guest)
on 2006-04-02 14:41
(Received via mailing list)
I'm trying to add an RSS feed to my app, and am going through the
Rails Recipes chapter on doing so.  I get the following error when I
request the feed:

undefined method `gmtime' for #<DateTime: 1963061961/800,0,2299161>
7:     xml.pubDate CGI.rfc1123_date(@posts.first.created_on)

Any idea what's up?

Pat M. (Guest)
on 2006-04-02 14:56
(Received via mailing list)
Also, checking out the RSS feed in NetNewsWire, it just says "Untitled
Source" and has no items.  I validated the feed and it validates fine.
 The raw XML looks exactly like the example in Rails Recipes.  Not
sure what's wrong with it.

Pat M. (Guest)
on 2006-04-02 16:38
(Received via mailing list)
hrm..I guess there's a problem with how Rails handles datetime's in
PostgreSQL?  Not sure.  Anyway I did a search on how to convert a
DateTime to a Time (since DateTime doesn't respond to #gmtime).  Put
this code in lib/date_time.rb

class DateTime
  def to_time
    Time.mktime(year, mon, day, hour, min, sec)

required it in environment.rb, and changed the builder template code to
xml.pubDate CGI.rfc1123_date(@posts.first.created_on.to_time)

Works for me.  If I'm doing something wrong, I'd like to know about
it, but I think it may just be a problem with Rails and postgres.

This topic is locked and can not be replied to.