Note that there are some explanatory texts on larger screens.

plurals
  1. POSet default database connection Rails
    primarykey
    data
    text
    <p>My rails app has its own MySql database (and requires the mysql2 gem) but also needs to connect with an external MongoDB database for one particular model (and so I've included mongoid and bson_ext in the Gemfile). Now when I try to generate a migration for a new model, it tells me that </p> <pre><code>$ rails g migration CreateLocations error mongoid [not found] </code></pre> <p>When I generated the Location model it included Mongoid::Document, so Rails obviously thinks it is using the external database as my primary datastore.</p> <p>databse.yml:</p> <pre><code>development: adapter: mysql2 encoding: utf8 reconnect: false database: associalize_development pool: 5 username: root password: socket: /tmp/mysql.sock </code></pre> <p>mongoid.yml:</p> <pre><code>development: host: pearl.mongohq.com port: 27019 username: asfasdf password: sadfasdf database: app4574678 test: host: pearl.mongohq.com port: 27019 username: asdfadhasdfa password: hadsadfas database: app4574678 production: host: pearl.mongohq.com port: 27019 username: asdfdfsasda password: afdasdfdasdf database: app4574678 </code></pre> <p><strong>UPDATE</strong> Model that uses Mongo</p> <pre><code>class ExternalMongoModel include Mongoid::Document field :title field :long_title field :deal_type field :merchandise_type field :market_id field :market_name field :market_location, type: Array field :featureType field :country_code field :subtitle field :offer_ends_at field :price field :value field :merchant_type field :content field :merchant index( [[:division_latlon, Mongo::GEO2D]], background: true ) end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload