开发者

Advanced Feed Parsing in Rails

I am a newbie to rails and I have been watching Rails Casts videos.

I am interested to know a little bit more on FeedZirra (Rails casts episode 168) and especially feed parsing.

For example, I need to Parse feeds from Telegraph and Guardian

I want to put all the sports news from both the newspapers in one table, just football news in another table, cricket news in another table etc

How can I achieve that using feed-zirra?

How do I display only football news in one view and only cricket news in another view?

Also, I want the user to know which website he is gonna visit before he actually clicks the link and finds out.

Something like this

Ryder Cup 2010: Graeme McDowell the perfect hero for Europe 5开发者_开发知识库 min ago | Telegraph.co.uk

How do I display Telegraph.co.uk

Looking forward for your help and support

Thanks


There are many questions there, but I'll take this one:

I just know how to put all feeds in table. I dont know how to keep feeds in different tables

  • Create different models to suit your data model, based on what information you need to show rather than what is provided in the feed. (Different tables for each models if required or Single Table Inheritance if possible)
  • Write a wrapper class that will use FeedZirra (or any other parser for that matter) to read the parsed feeds and process them. These are generally kept in the lib folder.
  • Create a rake task which can be called to run this script OR if you are familiar with delayed_job, then create a job.
  • Schedule your rake task through cron or your job through delayed_job, so that you can periodically update your data.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜