我想在我的Rails 3.2应用程序中使用Feedzirra来做简单的提要分析。我在网上发现:http://asciicasts.com/episodes/168-feed-parsing。我按照那里的说明来安装宝石,但我相信这些说明已经过时了,因为它指的是在我的config/environment.rb
文件中放置一个config.gem
行,它不能适应这种调用。我收到一个uninitialized constant ApplicationController::Feedzirra
错误,我不知道为什么。Feedzirra没有正确安装?
我把这个代码在我的应用程序控制器:
before_filter :load_blog_feed
def load_blog_feed
feed = Feedzirra::Feed.fetch_and_parse(feed_url)
@blog_posts = feed.entries[0...3]
end
我把此行config/application.rb
:
config.gem "pauldix-feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
最后,我把这个代码在一个视图:
<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>
所以我做了两个...,它不工作。 – Chiubaka