簡體   English   中英

語法錯誤,意外的tIDENTIFIER,期待';' 或'\\ n'

[英]syntax error, unexpected tIDENTIFIER, expecting ';' or '\n'

我只是在我的文件models / post.rb中復制並粘貼了教程中的代碼

class Post < ActiveRecord::Base
  attr_accessible :content, :name, :title

  validates :name,  :presence => true
  validates :title, :presence => true,
                    :length => { :minimum => 5 }
end

並收到一個錯誤:

SyntaxError: /home/row/blog/app/models/post.rb:1: syntax error, unexpected tIDENTIFIER, expecting ';' or '\n'
  ...idates :name,  :presence => true
...                               ^

我在代碼中做了一些更改,如:

class Post < ActiveRecord::Base
  attr_accessible :content, :name, :title

  validates :name,  :presence => true
  validates :title, :presence => true, :length => { :minimum => 5 }
end

但是出現了同樣的錯誤。 我很困惑。

你有錯誤的行結尾。 嘗試將它們更改為UNIX行結尾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM