我在Rails应用程序中使用的是Sequel,而不是Active Record。

如何配置它并连接到数据库?目前我正在使用

DB = Sequel.connect(ENV['DATABASE_URL'])


但我收到错误消息:

/home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `require': LoadError: cannot load such file -- sequel/adapters/sqlite3 (Sequel::AdapterNotFound)
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `block in tsk_require'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:100:in `block in check_requiring_thread'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:97:in `synchronize'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:97:in `check_requiring_thread'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:379:in `tsk_require'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:25:in `adapter_class'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/database/connecting.rb:55:in `connect'
    from /home/aaditya/Downloads/ruby-bench-suite/rails/vendor/bundle/ruby/2.3.0/gems/sequel-3.40.0/lib/sequel/core.rb:147:in `connect'
    from benchmarks/bm_sequel_create_string_columns.rb:4:in `<main>'


当我放入ENV['DATABASE_URL']时,得到以下输出:

sqlite3::memory:


正确的方法是什么?

最佳答案

使用Sequel gem时,适配器称为sqlite,而不是sqlite3

关于ruby-on-rails - `require':LoadError:无法加载此类文件-sequel/adapters/sqlite3(Sequel::AdapterNotFound),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37776152/

10-14 06:33