# Problem with RSS feed from Rails Recipes

**URL:** <https://www.ruby-forum.com/t/problem-with-rss-feed-from-rails-recipes/93422>\
**Category:** Rails\
**Created:** [April 2, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/problem-with-rss-feed-from-rails-recipes/93422 "2006-04-02T12:41:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 2, 2006, 12:41pm UTC](https://www.ruby-forum.com/t/problem-with-rss-feed-from-rails-recipes/93422/1 "2006-04-02T12:41:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 2, 2006, 12:56pm UTC](https://www.ruby-forum.com/t/problem-with-rss-feed-from-rails-recipes/93422/2 "2006-04-02T12:56:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [April 2, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/problem-with-rss-feed-from-rails-recipes/93422/3 "2006-04-02T14:38:15Z")

</div>

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)  
end  
end

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.

Pat
