我正在尝试创建一个 gem 来为遗留数据库提供模型,但我的 gem 看不到应用程序的配置:
在我的 database.yml 中:
firefly:
adapter: mysql2
database: ...
username: ...
password: ...
模型,在宝石中:
module FireflyRails
class User < ActiveRecord::base
establish_connection :firefly
set_table_name "fly_users"
end
end
我在常规的 Rails 应用程序中对此进行了原型设计,并且能够毫无问题地从数据库中读取。但是,当从 gem 中使用时,我什至无法启动控制台:
缩写回溯:
/Users/Jeff/.rvm/gems/ruby-1.9.3-p327@lunar/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in **`resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)**
from /Users/Jeff/.rvm/gems/ruby-1.9.3-p327@lunar/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Users/Jeff/.rvm/gems/ruby-1.9.3-p327@lunar/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
from /Users/Jeff/.rvm/gems/ruby-1.9.3-p327@lunar/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
我在网上找到的示例似乎都使用标准 rails 数据库,我找不到使用不同数据库配置的 gem 示例。
我在这里想念什么?