Ruby on rails 验证时出现语法错误!(一个月的麻烦)!

Ruby on rails 验证时出现语法错误!(一个月的麻烦)!,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我正在做一个月的rails,遇到了关于上传PIN码的教程,下面是我键入的内容(正如视频所说,这是正确的) 我遵循了语法错误,但仍然不起作用。删除了结尾处的逗号,但不起作用。已经挣扎了几个小时,在网站上也找不到类似的东西。对不起,我的问题是noob。谢谢你的回复!:) 小于应该是一个键 尝试: class Pin < ActiveRecord::Base attr_accessible :description, :image validates :description, pre

我正在做一个月的rails,遇到了关于上传PIN码的教程,下面是我键入的内容(正如视频所说,这是正确的)


我遵循了语法错误,但仍然不起作用。删除了结尾处的逗号,但不起作用。已经挣扎了几个小时,在网站上也找不到类似的东西。对不起,我的问题是noob。谢谢你的回复!:)

小于
应该是一个

尝试:

class Pin < ActiveRecord::Base
  attr_accessible :description, :image

  validates :description, presence: true
  validates :user_id, presence: true
  validates_attachment :image, presence: true,
                content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'] },
                size: {less_than 5.megabytes}
  belongs_to :user
  has_attached_file :image 
end
syntax error, unexpected tINTEGER, expecting keyword_do or '{' or '(' size: {less_than 5.megabytes} ^ /Users/code/omrails/app/models/pin.rb:8: syntax error, unexpected '}', expecting keyword_end
validates_attachment :image, presence: true,
  content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'] },
  size: {less_than: 5.megabytes}