Domanda

I am building a gem to annotate Sequel models in Rails projects: https://github.com/kennym/annotate-sequel

It is not working yet, because whenever I require a Rails model to parse its schema information I am getting the following error:

No database associated with Sequel::Model: have you called Sequel.connect or Sequel::Model.db=

I do understand what the error is about, but I would like to gather your feedback on how you could get the Rails connection details from within the gem, without supplying that information separately.

Looking forward to read your answers!

È stato utile?

Soluzione

I fixed this by loading the Rails environment via requiring config/environment.rb

require 'config/environment'

in my gem.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top