Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么我会得到一个“a”;未初始化的常量提要::Feedzirra“;错误_Ruby On Rails_Ruby On Rails 3.1_Rss_Feedzirra - Fatal编程技术网

Ruby on rails 为什么我会得到一个“a”;未初始化的常量提要::Feedzirra“;错误

Ruby on rails 为什么我会得到一个“a”;未初始化的常量提要::Feedzirra“;错误,ruby-on-rails,ruby-on-rails-3.1,rss,feedzirra,Ruby On Rails,Ruby On Rails 3.1,Rss,Feedzirra,我正在开发一个RubyonRails-v3.1.3应用程序,需要下载rss提要。通过将feedzirra添加到我的GEM文件并运行bundle install,我已成功安装了feedzirra 在我的控制器中,用于显示我拥有的rss提要的页面 @feed=feed.new(这里是blog\u url) 我的模型文件夹中有一个名为Feed.rb的类,其中包含以下内容: def initialize(endpoint) atom = Feedzirra::Feed.fetch_and_par

我正在开发一个RubyonRails-v3.1.3应用程序,需要下载rss提要。通过将feedzirra添加到我的GEM文件并运行
bundle install
,我已成功安装了feedzirra

在我的控制器中,用于显示我拥有的rss提要的页面

@feed=feed.new(这里是blog\u url)

我的模型文件夹中有一个名为Feed.rb的类,其中包含以下内容:

def initialize(endpoint)
    atom = Feedzirra::Feed.fetch_and_parse endpoint
    @atom = atom.is_a?(Feedzirra::Parser::Atom) ? atom : nil
end

当我加载页面时,我得到一个“未初始化常量Feed::Feedzirra”错误。有人知道我为什么以及如何修复它吗?

也许它会帮助某人:


您应该在
捆绑安装后重新启动
rails服务器

,不幸的是,这可能是由许多不同的原因造成的
@feed=feed.new(blog_url_此处)
此代码是否包含在某些方法中,如
def new
?尝试在Ruby模型顶部添加
require'feedzirra'
。此外,您可能会遇到问题,因为您的文件名为feed.rb,并且您正在调用名为feed的类。。尝试将您的模型重命名为其他版本,我发现更多代码会有所帮助@garbagecollection,是的,该行在我的BlogController上的索引操作中。@dennismonsewicz my Feed.rb定义提要类,即类提要。。。。终止initialize方法在此类中。我曾试着要求feedzirra,但由于某种原因,这不起作用。我最终选择了使用其他的东西。谢谢