简体   繁体   English

Ruby on Rails语法错误-似乎无法解决

[英]Ruby on Rails Syntax Error - seems unsolvable

Newbie here, and trying to use CarrierWave to upload an image. 新手在这里,并尝试使用CarrierWave上传图像。 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 C:/Sites/redemo/app/models/listing.rb:2:语法错误,意外的tCONSTANT,期望keyword_end

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

Rails.root: C:/Sites/redemo Rails.root:C:/ Sites / redemo

Application Trace | 应用程序跟踪| Framework Trace | 框架跟踪 Full Trace app/controllers/listings_controller.rb:7:in `index' Full Trace app / controllers / listings_controller.rb:7:in`index'

However, when I check listing.rb this is what I see 但是,当我检查listing.rb时,这就是我看到的

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方法参数中缺少逗号:

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. 基本上, mount_uploader是一种与其他方法一样的方法,它接收2个参数,因此需要用逗号分隔。

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

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