没有名为“activerecord-sqlite3-ruby-adapter”的 gem

发布于 2024-08-18 13:20:29 字数 1708 浏览 2 评论 0原文

我正在尝试使用本机 ruby​​ 1.8 在 sqlite3 数据库之上设置活动记录。这应该很容易工作,我已经看到了很多解释如何操作的例子。我正在使用我找到的一些示例代码,它非常基本,并以以下几行开头:

require 'rubygems'
require 'active_record'
#require 'sqlite3-ruby'

...

ActiveRecord::Base.establish_connection(
    :adapter => "sqlite3-ruby",
    #:dbfile  => ":memory:"
    :database  => ":memory:"
    #:database  => "/home/fgysin/bender/gen2/metaDB/testing/sql3.db"
)

ActiveRecord::Schema.define do  
  create_table :albums do |table|
    table.column :title, :string
    table.column :performer, :string
  end

  create_table :tracks do |table|
    table.column :album_id, :integer
    table.column :track_number, :integer
    table.column :title, :string
  end
end


但是当我运行这个示例时(它会创建一些表并打印一些简单的统计信息),我收到以下错误:

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:
76:in `establish_connection':
Please install the sqlite3-ruby adapter:
`gem install activerecord-sqlite3-ruby-adapter`

(no such file to load -- active_record/connection_adapters/sqlite3-ruby_adapter) (RuntimeError)
from 2nd.generation/ActiveRecordExample.rb:8

我尝试安装该 activerecord-sqlite...gem 但在任何地方都找不到它。我用谷歌搜索,也没有找到那个宝石名称。

安装了以下与 sqlite/activerecords 相关的 gem:
(我安装了“activerecord”、“sqlite3-ruby”和“activerecord-jdbcsqlite3-adapter”,尽管后者将用于 JRuby...)

activerecord (2.3.5, 2.3.4, 2.2.2, 2.1.0)
activerecord-jdbc-adapter (0.9.2)
activerecord-jdbcsqlite3-adapter (0.9.2)
sqlite3-ruby (1.2.5)
dbd-sqlite3 (1.2.5)
jdbc-sqlite3 (3.6.3.054)

任何人都可以建议解决我的问题吗?我真的不知道如何找到/安装 sqlite3/activerecords 所需的适配器。怎么称呼?显然不是错误消息建议的适配器,因为在本地或存储库中找不到它......

I am trying to set up active records on top of a sqlite3 database with native ruby 1.8. This should work easily enough, I have seen plenty of examples out there that explain how. I am using some example code I have found, its pretty basic and starts with the following lines:

require 'rubygems'
require 'active_record'
#require 'sqlite3-ruby'

...

ActiveRecord::Base.establish_connection(
    :adapter => "sqlite3-ruby",
    #:dbfile  => ":memory:"
    :database  => ":memory:"
    #:database  => "/home/fgysin/bender/gen2/metaDB/testing/sql3.db"
)

ActiveRecord::Schema.define do  
  create_table :albums do |table|
    table.column :title, :string
    table.column :performer, :string
  end

  create_table :tracks do |table|
    table.column :album_id, :integer
    table.column :track_number, :integer
    table.column :title, :string
  end
end

But when I run this example (it would create some tables and print some simple stats) I get the following error:

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:
76:in `establish_connection':
Please install the sqlite3-ruby adapter:
`gem install activerecord-sqlite3-ruby-adapter`

(no such file to load -- active_record/connection_adapters/sqlite3-ruby_adapter) (RuntimeError)
from 2nd.generation/ActiveRecordExample.rb:8

I tried installing that activerecord-sqlite... gem but it is not found anywhere. I searched with google and it got me no hits on that gem name either.

The following gems related with sqlite/activerecords are installed:
(I installed 'activerecord', 'sqlite3-ruby' and 'activerecord-jdbcsqlite3-adapter' allthoug the latter would be used for JRuby...)

activerecord (2.3.5, 2.3.4, 2.2.2, 2.1.0)
activerecord-jdbc-adapter (0.9.2)
activerecord-jdbcsqlite3-adapter (0.9.2)
sqlite3-ruby (1.2.5)
dbd-sqlite3 (1.2.5)
jdbc-sqlite3 (3.6.3.054)

Can anyone please suggest a solution to my problem? I really do not see how I can find/install the needed adapter for sqlite3/activerecords. How is it called? It is obviously not the adapter that is suggested by the error message as it is not found locally or in a repository...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

权谋诡计 2024-08-25 13:20:30

只是在黑暗中拍摄,但您是否尝试更改::

adapter => “sqlite3-ruby”,

:adapter => “sqlite3”,

Just a shot in the dark, but did you try changing:

:adapter => "sqlite3-ruby",

to

:adapter => "sqlite3",

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文