一旦我添加代码来访问我的 .sqlite 数据库,我就会收到一个奇怪的错误:
in 'total': uninitialized constant Test2::SQLite (NameError)
我的代码如下:
测试1.rb
require_relative 'Test2.rb'
co = Test2.new()
price = co.total
测试2.rb
require 'sqlite3'
class Test2
def initialize()
@items = []
end
def total()
db = SQLite::Database.open "Database.sqlite"
db.close()
return 0
end
end