新手问题 syntax error, unexpected '<', expecting keyword_end <strong> has_many :comments </strong> ^错误怎么解决

lianyutao · 2013年07月29日 · 最后由 tiseheaini 回复于 2013年07月30日 · 6527 次阅读
class Post < ActiveRecord::Base
    validates :name, :presence => true
    validates :title, :presence => true, :length => { :minimum => 5}
        <strong> has_many :comments </strong> 
end

错误

/home/tao/blog/app/models/post.rb:4: syntax error, unexpected '<', expecting keyword_end <strong> has_many :comments </strong> ^ /home/tao/blog/app/models/post.rb:4: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' <strong> has_many :comments </strong> ^ /home/tao/blog/app/models/post.rb:4: unterminated regexp meets end of file /home/tao/blog/app/models/post.rb:4: syntax error, unexpected end-of-input, expecting keyword_end

该怎么解决 又是什么意思????

我来贴楼主源码

class Post < ActiveRecord::Base
    validates :name, :presence => true
    validates :title, :presence => true, :length => { :minimum => 5}
        <strong> has_many :comments </strong> 
end

谁把错误提示也分一下段 看着闹心

哦 html 写入 model.rb 文件大丈夫?

LZ 源码亮了。

这。。。。

这……。。。

楼主的源码是复制的 CSDN blog 里的吧?

<strong> has_many :comments </strong> 

这个帖子很纠结。。。😱

这是来围观的,不是来顶帖子的

去掉 <strong></strong> 这两个标签不是 Ruby 代码

各位,要友好…

看来我带了坏头,早上正在忙开发,不想回复,就把楼主帖子源码贴出来,想着楼下会有人回答。结果自己成了坏榜样,我应该要不不回复,要不回复清楚。

#15 楼 @lianyutao 建议楼主先学学 Ruby 语法

- -。直接复制粘贴是不靠谱的

看完楼主的 ruby,我只想说, “我艹!程序还可以这么写呢!!!” ps: 楼主不过不要桑心,大家开始时都这样

#19 楼 @blackanger 我修改了回复,怕伤到楼主,之前我就被伤过~~~

需要 登录 后方可回复, 如果你还没有账号请 注册新账号