繁体   English   中英

无法自动加载常量,期望FILEPATH定义它 - 换句话说,是吧?

[英]Unable to autoload constant, expecting FILEPATH to define it - in other words, huh?

当我尝试访问我的localhost时,收到以下消息。

** ListingsController #index中的LoadError

无法自动加载常量清单,预期C:/Sites/redemo/app/models/listing.rb来定义它**

这是它在listings_controller.rb中引用的代码

# GET /listings.json
  def index
    @listing =Listing.all
  end

我的listing.rb如下:

 class Listings < ActiveRecord::Base
        mount_uploader :image, ImageUploader
 end

拜托,我还应该做些什么来定义它?

您检查模型定义。 虽然控制器是Listings ,但模型应该是Listing因此更改为此;

class Listing < ActiveRecord::Base
     mount_uploader :image, ImageUploader
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM