续集示例不会运行

时间:2010-07-12 12:31:09

标签: ruby yaml sequel

我刚为Ruby安装了“续集”宝石。我想试试Sequel网站的例子,它不会起作用:( test.rb:

require 'rubygems'
require 'sequel'

DB = Sequel.sqlite # memory database

DB.create_table :items do
    primary_key :id
    String :name
    Float :price
end

items = DB[:items] # Create a dataset

# Populate the table
items.insert(:name => 'abc', :price => rand * 100)
items.insert(:name => 'def', :price => rand * 100)
items.insert(:name => 'ghi', :price => rand * 100)

# Print out the number of records
puts "Item count: #{items.count}"

# Print out the average price
puts "The average price is: #{items.avg(:price)}"

控制台:

$ sequel test.rb
Error: ArgumentError: syntax error on line 11, col 37: `i'/usr/lib/ruby/1.8/yaml.rb:133:in `load'

1 个答案:

答案 0 :(得分:2)

您需要使用ruby而不是sequel

来运行此功能
$ ruby test.rb