<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Skin of Stars &#187; ruby</title>
	<atom:link href="http://skinofstars.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://skinofstars.com</link>
	<description>Machines, Media and Miscellanea</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:17:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
<cloud domain='skinofstars.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Ruby On Rails, RSS and Atom feed parsing with Feed Normalizer and subsequent storage</title>
		<link>http://skinofstars.com/2009/03/ruby-on-rails-rss-and-atom-feed-parsing-with-feed-normalizer-and-subsequent-storage/</link>
		<comments>http://skinofstars.com/2009/03/ruby-on-rails-rss-and-atom-feed-parsing-with-feed-normalizer-and-subsequent-storage/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 02:47:10 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Programming & Design]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve battled for days on this, but I now finally know how to parse feeds and store them in a database in Ruby On Rails. This won&#8217;t be of much interest to the casual reader, but if you are scouring the web for an answer (as I was) then you will probably find this very useful: class Feed &#60; ActiveRecord::Base<a href="http://skinofstars.com/2009/03/ruby-on-rails-rss-and-atom-feed-parsing-with-feed-normalizer-and-subsequent-storage/"> ...&#160;Read the remaining 81 words</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve battled for days on this, but I now finally know how to parse feeds and store them in a database in Ruby On Rails. This won&#8217;t be of much interest to the casual reader, but if you are scouring the web for an answer (as I was) then you will probably find this very useful:</p>
<p><code><br />
class Feed &lt; ActiveRecord::Base<br />
require_association 'post'<br />
require 'feed-normalizer'<br />
require 'open-uri'<br />
require 'rss/2.0'<br />
<code><br />
belongs_to :user<br />
has_many :posts, :dependent =&gt; :destroy<br />
<code><br />
#put some other stuff here for feed validation etc<br />
<code><br />
def refresh_all<br />
refresh(Feed.find(:all))<br />
end<br />
<code><br />
def refresh(feeds)<br />
feeds.each do |feed|<br />
rss = FeedNormalizer::FeedNormalizer.parse open(feed.uri)<br />
rss.entries.each  do |item|<br />
post = Post.new(:feed_id =&gt; feed.id)<br />
post.link = item.url or raise "post has no link tag"<br />
post.title = item.title or "no title"<br />
post.content = item.content or "no text"<br />
post.created_at = item.date_published if item.date_published<br />
post.save<br />
end<br />
end<br />
<code>end</code></code></code></code></code></code></p>
<p>end</p>
]]></content:encoded>
			<wfw:commentRss>http://skinofstars.com/2009/03/ruby-on-rails-rss-and-atom-feed-parsing-with-feed-normalizer-and-subsequent-storage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

