I'm trying to use Feedzirra in my Rails 3.2 app to do simple feed parsing. I found this online: http://asciicasts.com/episodes/168-feed-parsing. I followed the instructions there to install the gem, but I believe this instructions are somewhat out of date, since it refers to placing a config.gem
line in my config/environment.rb
file, which cannot accommodate such calls. I am getting an uninitialized constant ApplicationController::Feedzirra
error and I'm not sure why.
I put this code in my application controller:
before_filter :load_blog_feed
def load_blog_feed
feed = Feedzirra::Feed.fetch_and_parse(feed_url)
@blog_posts = feed.entries[0...3]
end
I placed this line in config/application.rb
:
config.gem "pauldix-feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
Lastly, I placed this code in a view:
<div id="blog_feed">
<% @blog_posts.each do |post| %>
<p>
<span class="post_title"><%= link_to "#{post.title} >>", post.url %></span><br>
by <span class="post_author"><%= post.author %></span> on <span class="post_date"><%= post.published %></span>
</p>
<% end %>
</div>
Ok, I found the answer... just include gem 'feedzirra'
in your Gemfile and run bundle install
. gem 'pauldix-feedzirra'
doesn't seem to work, though.