我刚开始从务实的程序员'Agile Web Development with Rails'那里学习Ruby on Rails。
我写了一个小应用程序,当我运行它时,我收到以下语法错误:
/Users/colinlabri/Desktop/depot/app/models/product.rb:2: syntax error, unexpected ':', expecting keyword_end
attr_accessible : title, :description, :image_url, :price
^
/Users/colinlabri/Desktop/depot/app/models/product.rb:2: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
attr_accessible : title, :description, :image_url, :price
^
Rails.root: /Users/colinlabri/Desktop/depot
Application Trace | Framework Trace | Full Trace
app/controllers/products_controller.rb:1:in `<top (required)>'
DB的代码如下:
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string : title
t.text :description
t.string :image_url
t.decimal :price, precision: 8, scale: 2
t.timestamps
end
end
end
版本如下: ruby 1.9.3p362 Rails 3.2.11
我应该检查我的 sqlite 安装吗?如何检查?