Atom Feeds, Rails 3.1

Hey everyone,
I’ve got a strange (or so I think) error with my Atom feed for my
company’s blog system. I’ve only started implementing it today and I
can’t seem to find too much documentation on it unfortunately.\ This
issue I have is that I get:

undefined method `post_url’ for
#<#Class:0x0000000a7277c0:0x0000000a6ffae0>, and it finds the
extracted source to be from line 5 of feed.atom.builder ( feed.entry
post do |entry| , also shown below )

Blog Controller

def feed
@posts = Post.order(‘id desc’).limit(10)
respond_to do |format|
format.atom
end
end

feed.atom.builder

atom_feed :language => ‘en-US’ do |feed|
feed.title “CoverHound.com Blog”
feed.updated @posts.order(‘id desc’).first.created_at
@posts.each do |post|
feed.entry post do |entry|
entry.title post.title
entry.url blog_post_url(:title => post.url_title)
entry.summary post.abstract, :type => ‘html’
entry.author post.author.name
end
end
end

routes


match ‘/blog/feed’ => ‘blog#feed’, :as => :blog_feed, :defaults => {
:format => ‘atom’ }

The strange thing about this error is that I don’t specify post_url
anywhere in the builder… Somehow, it automatically wants to use that
route helper. However, my routes are setup like blog_post_url and not
just post_url.

Anyone have any ideas?

Thanks!!

  • Jeff

Well, I actually figured this one out. Looking at the source, the
AtomFeedHelper was grabbing the URL automatically from the record, which
is wrong, since it’s not stored anywhere in the record itself and the
namespace is slightly different than rails conventions (blog_post_url
instead of post_url). I was able to pass the URL parameter into the
troublesome statement and it works now:

What was:
feed.entry post do |entry|

Is now:
feed.entry(post, :url => blog_post_url(:title => post.url_title)) do
|entry|

Resolved! Thanks,

  • Jeff