这是我的代码:
初始化文件:
require 'sequel'
DB = Sequel.connect('sqlite://data.db')
DB.drop_table?(:restaurants)
DB.create_table :restaurants do
primary_key :id
String :name
end
DB.drop_table?(:category)
DB.create_table :category do
primary_key :id
String :name
end
DB.drop_table?(:items)
DB.create_table :items do
primary_key :id
foreign_key :restaurant_id
foreign_key :category_name
String :name
Float :price
end
require_relative './restaurant'
require_relative './categories'
require_relative './item'
应用程序文件:
require_relative './models/init
p = Category.create(:name => 'Pizza')
c = Category.create(:name => 'Calazone')
pa = Category.create(:name => 'Pasta')
s = Category.create(:name => 'Salad')
d = Category.create(:name => 'Dessert')
dr = Category.create(:name => 'Drink')
si = Category.create(:name => 'Side')`
但我收到此错误:
/home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:1780:in `block in set_restricted': method name= doesn't exist (Sequel::Error)
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:1767:in `each'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:1767:in `set_restricted'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:1278:in `set'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:1736:in `initialize_set'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:920:in `initialize'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:156:in `new'
from /home/ben/.rvm/gems/ruby-1.9.3-p385/gems/sequel-3.45.0/lib/sequel/model/base.rb:156:in `create'
from app.rb:4:in `<main>'"
请帮忙。
谢谢