Hi all,
Rails 2 makes the Atom RSS Feed much more sophisticated and elegant. If you are using the Ruby on Rails by RubyGems installer, maybe you have an old version of the Atom Feed Helper. To fix it you can check out the atom_feed_helper version inside the Ruby on Rails repository and after that, copy and paste it to /vendor/plugins/ directory.
The repository is:
http://svn.rubyonrails.org/rails/plugins/atom_feed_helper.
In there you will find plugins that are more up to date.
In the README you will find a simple example to build your feed. Like when you click in our Cnxs feed at the navigation bar, if you are browsing with Firefox.
Here comes our example:
atom_feed(:schema_date => @posts.last.created_at.year) do |feed|
feed.title("CNXS")
feed.updated(@posts.first ? @posts.first.created_at : Time.now.utc)
@posts.each do |post|
feed.entry(post) do |entry|
entry.title(post.title)
entry.content(post.body, :type => 'html')
entry.author do |author|
author.name(post.user.name)
author.email(post.user.email)
end
end
end
end
You can note the the atom_feed method has 4 arguments, but just one of them is required, that is the :schema_date. You can read at
http://feedvalidator.org/docs/error/InvalidTAG.html, you see that the URI tag needs a year to be fix in the validators, month and day parts are optional. The others arguments are :language, that defaults to "en-US", :root_url, that defaults to the root path on the current host and :url that defaults to the current URL.
Another thing that you can look is that the ".builder" extension has higher precedence. So, if you code it in your rss action in the PostsController:
respond_to do |format|
format.atom { render :layout => false }
end
the atom format respond int the same way to rss.builder and rss.atom.builder.
See you.