Generating migrations with couchrest_model

How you can go about generating migrations with couchrest_model

CouchRest_Model is a lovely way to handle CouchDB calls from without your rails app, it provides an Active Record like interface to your data.

In a project I am working on at the moment I am using both CouchRest_Model and Active Record at the same time, which isn't a problem at all and they normally don't stand on each others feet.

I say normally because one time when it can cause issue is whenever you are generating migrations using the command rails generate migration myMigration.

You may find that if you run this you will get the following error;

error  couchrest_model [not found]

This is because CouchRest_Model assumes it is the default ORM, which is fine in the app, but not find for migration generation.

To get around this we can add a flag to our migration command;

rails generate migration myMigration --orm=active_record

This will allow the migration to generate as expected.


Recent posts View all

Ruby

How to ignore Bullet in RSpec tests

Using Bullet during a test can pick up mistakes but also has false negatives; here is an easy way to ignore them

Ruby

How we used Nokogiri to fix a sizing issue in YouTube's oEmbed

At some point, one of our calls to YouTube's oEmbed endpoint was returning videos way too small; we fixed in in our Rails application by using Nokogiri