我正在关注RoR下载网站上的博客应用.教程说输入此代码以获得一些验证:
class Post < ActiveRecord::Base
validates :name, :presence => true
validates :title, :presence => true,
:length => { :minimum => 5 }
end
Run Code Online (Sandbox Code Playgroud)
我的副本中有这个:
class Post < ActiveRecord::Base
validates :name, :presence => true,
validates :title, :presence => true,
:length => { :minimum => 5 }
end
Run Code Online (Sandbox Code Playgroud)
据我所知,这是正确的,但是当我运行页面时,我收到这些错误消息:
c:/Sites/blog/app/models/post.rb:3: syntax error, unexpected tSYMBEG, expecting kDO or '{' or '('
validates :Title, :presence => true,
^
C:/Sites/blog/app/models/post.rb:3: Can't assign to true
C:/Sites/blog/app/models/post.rb:4: syntax error, unexpected tASSOC, expecting tCOLON2 or '[' or '.' …Run Code Online (Sandbox Code Playgroud)