I know there is alot of hype around rails both good and bad with some developers choosing to bad mouth it as "...not robust, flimsy and too easy to bother learning... " but so far I've found it no harder nor easier than most other languages and frameworks I've used. It's the simple pain-in-the-arse functionality this RoR excels in the stuff I'm glad to be rid of such as the creation of an atom feed for my blog posts. Look at this stupidly simple example that I used to create an atom feed for all the posts in my blog.
FILENAME - index.rss.builder
# rss.builder
atom_feed(:schema_date => @posts.last.created_at.year) do |feed|
feed.title("Jackson Charles")
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(post.tag)
end
end
end
FILENAME - posts.controller.rb
def index
@posts = Post.find(:all, :conditions => ["status = ?", 1], :order => 'created_at desc')
respond_to do |format|
format.html # index.html.erb
format.rss
end
end
Then I dropped a suitable link in the header section of my appropiate layout file and it was all done!
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://jacksoncharles.co.uk/posts.rss" />
All done ![]()