简体   繁体   中英

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.

**LoadError in ListingsController#index

Unable to autoload constant Listing, expected C:/Sites/redemo/app/models/listing.rb to define it**

This is the code it refers to in listings_controller.rb

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

My listing.rb is as follows:

 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;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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