Question

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!

Was it helpful?

Solution

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

require 'config/environment'

in my gem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top