[英]Unable to autoload constant, expecting FILEPATH to define it - in other words, huh?
When I try to access my localhost, I get the following message. 当我尝试访问我的localhost时,收到以下消息。
**LoadError in ListingsController#index ** ListingsController #index中的LoadError
Unable to autoload constant Listing, expected C:/Sites/redemo/app/models/listing.rb to define it** 无法自动加载常量清单,预期C:/Sites/redemo/app/models/listing.rb来定义它**
This is the code it refers to in listings_controller.rb 这是它在listings_controller.rb中引用的代码
# GET /listings.json
def index
@listing =Listing.all
end
My listing.rb is as follows: 我的listing.rb如下:
class Listings < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
Please, what else am I supposed to do to define it? 拜托,我还应该做些什么来定义它?
You check your model definition. 您检查模型定义。 While controller is
Listings
, model should be Listing
Therefore change to this; 虽然控制器是
Listings
,但模型应该是Listing
因此更改为此;
class Listing < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.