1

我想在我的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> 

回答

0

好吧,我找到了答案...只是在您的Gemfile gem 'feedzirra'和运行bundle installgem 'pauldix-feedzirra'似乎不起作用,但。

0

使用Bundler!

地方

----- EDITED

gem 'feedzirra'

到Gemfile中,然后运行bundle install

+0

所以我做了两个...,它不工作。 – Chiubaka

1

对于滑轨3.2,更精确地说,下面的行/ application.rb中文件添加到配置:

config.gem "feedzirra", :lib => "feedzirra", :source => "http://gems.github.com" 

和下面的行向的Gemfile

gem 'feedzirra' 

然后运行:

bundle install 

然后,您可以顺利地在您的应用程序中使用feedzirra。