简体   繁体   中英

Ruby on Rails Syntax Error - seems unsolvable

Newbie here, and trying to use CarrierWave to upload an image. However when I get to localhost this error message keeps popping up

C:/Sites/redemo/app/models/listing.rb:2: syntax error, unexpected tCONSTANT, expecting keyword_end

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

Rails.root: C:/Sites/redemo

Application Trace | Framework Trace | Full Trace app/controllers/listings_controller.rb:7:in `index'

However, when I check listing.rb this is what I see

class Listings < ActiveRecord::Base
    mount_uploader :image ImageUpLoader
end

Am I missing something obvious here? I've tried looking through similar posts to no avail. Please help, thank you!

You're missing a comma in your mount_uploader method arguments:

mount_uploader :image, ImageUpLoader

Basically, mount_uploader is a method like any other and it's receiving 2 arguments so they need to be delimited by a comma.

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