红宝石sqlite3 sinatra不能做db:迁移

时间:2018-11-14 09:48:50

标签: ruby sqlite sinatra

我正在使用w10 64位

app.rb

require 'rubygems'
require 'sinatra'
require "sinatra/activerecord"
require 'sqlite3/sqlite3_native'


class App < Sinatra::Base
  #configuraciones
  set :root, File.dirname(__FILE__)
  set :session_secret, 'super secret'
  set :public_folder, File.dirname(__FILE__) + '/public'
  set :layout, 'views/layouts'
  ActiveRecord::Base.establish_connection(
    :adapter => 'sqlite3',
    :database =>  'data.db'
  )
  enable :sessions
  #before all requests
  before do
    headers['server'] = 'Ruby, Ubuntu'
  end

end

rakefile.rb

require "sinatra/activerecord/rake"
require 'sqlite3/sqlite3_native'
require 'sinatra'
require './app'

gemfile

source "https://rubygems.org"

gem "sinatra"
gem "json"
gem 'sinatra-activerecord', '~> 2.0', '>= 2.0.9'
gem 'rake'
gem 'sqlite3'

所以当我尝试执行db:migrate时,我无法做到,sqlite3版本1.3.13 执行命令

bundle exec rake db:migrate
rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

所以我不知道到底是什么问题需要帮助

更新

我在rakefile.rb中更改仅需要'sqlite3' 但知道我遇到其他错误

rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

Caused by:
LoadError: cannot load such file -- sqlite3/2.5/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

1 个答案:

答案 0 :(得分:0)

尝试从sqlite3_native中删除rakefile.rb,只需要sqlite3