从gem连接到旧数据库

时间:2013-05-03 19:19:53

标签: ruby-on-rails-3 activerecord gem

我正在尝试创建一个gem来为遗留数据库提供模型,但我的gem无法看到应用程序的配置:

在我的database.yml中:

firefly:
  adapter: mysql2
  database: ...
  username: ...
  password: ...

模型,在gem中:

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的示例。

我在这里缺少什么?

0 个答案:

没有答案
相关问题