I have a Rails site. I want to create a news feed.
Does anyone have any pointers/advice/caution with this?
What are some common schemas?
We're using ActiveRecord+MySQL (at least for now), should that be sufficient, or is NoSQL the way to go?
I have a Rails site. I want to create a news feed.
Does anyone have any pointers/advice/caution with this?
What are some common schemas?
We're using ActiveRecord+MySQL (at least for now), should that be sufficient, or is NoSQL the way to go?
Well, a feed is just a representation of your content in some format suitable for RSS readers.
1) Generate the feed using XML Builder.
Controller:
@articles = Post.find :all
respond_to do |format|
format.html
format.rss { render :layout => false }
end
View (myfeed.rss.builder
):
xml.instruct! :xml, :version => "1.0"
xml.rss :version => "2.0" do
xml.channel do
xml.title "My RSS feed"
xml.link articles_url
for art in @articles
xml.item do
xml.title art.title
xml.description art.annotation
xml.pubDate art.created_at.to_s(:rfc822)
xml.link article_url(post)
end
end
end
end
2) Use the atom_feed
helper in Rails. Check it here.