Reputation: 789
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>
Upvotes: 1
Views: 681
Reputation: 34338
For Rails 3.2 , to be more precise, add the following line to config/application.rb file :
config.gem "feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
and following line to Gemfile :
gem 'feedzirra'
Then run :
bundle install
Then you can use feedzirra in your application smoothly.
Upvotes: 1
Reputation: 1835
use Bundler!
place
----- EDITED
gem 'feedzirra'
into Gemfile, and run bundle install
Upvotes: 0
Reputation: 789
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.
Upvotes: 0