-1
我正在开发一个ruby on rails -v 3.1.3应用程序,需要拉下一个rss feed。我已成功安装feedzirra,将其添加到我的gemfile并运行bundle install
。为什么我会收到“未初始化的常量Feed :: Feedzirra”错误?
在我的控制器将显示RSS提要的页面我有
@feed = Feed.new(blog_url_here)
,我有一个在我的模型文件夹命名Feed.rb类,它包含此:
def initialize(endpoint)
atom = Feedzirra::Feed.fetch_and_parse endpoint
@atom = atom.is_a?(Feedzirra::Parser::Atom) ? atom : nil
end
当我加载页面时,出现“未初始化的常量Feed :: Feedzirra”错误。任何人都知道我为什么以及如何修复它?
不幸的是,这可能是由许多不同的事情造成的。 '@feed = Feed.new(blog_url_here)'这个代码在'def new'之类的方法中吗? –
尝试在Ruby模型的顶部添加'require'feedzirra'' – dennismonsewicz
另外,您可能会遇到问题,因为您的文件名为Feed.rb,并且您正在调用一个名为Feed的类。尝试将模型重命名为某个东西否则 – dennismonsewicz