【问题标题】:Unable to autoload constant, expecting FILEPATH to define it - in other words, huh?无法自动加载常量,期望 FILEPATH 来定义它 - 换句话说,嗯?
【发布时间】:2014-06-06 22:16:09
【问题描述】:

当我尝试访问本地主机时,我收到以下消息。

**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

请问,我还应该做什么来定义它?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 constants autoload


    【解决方案1】:

    您检查您的模型定义。控制器为Listings,模型应为Listing 所以改成这个;

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-25
      • 1970-01-01
      • 2019-01-28
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多