title: Connecting to legacy database from a gem
body: <p>I am trying to create a gem to provide models for a legacy database but my gem can't see the app's configuration:</p>
  
  <p>In my database.yml:</p>
  
  <pre><code>firefly:
    adapter: mysql2
    database: ...
    username: ...
    password: ...
  </code></pre>
  
  <p>model, in the gem:</p>
  
  <pre><code>module FireflyRails
    class User &lt; ActiveRecord::base
      establish_connection :firefly
      set_table_name "fly_users"
  
    end
  end
  </code></pre>
  
  <p>I prototyped this in a regular rails app, and was able to read from the database without issue. However, when used from the gem, I can't even start the console:</p>
  
  <p>Abbreviated backtrace:</p>
  
  <pre><code>/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'
  </code></pre>
  
  <p>The examples I've found around the web all seem to use the standard rails database, I can't find an example of a gem using a different database configuration. </p>
  
  <p>What am I missing here?</p>