문제

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!

도움이 되었습니까?

해결책

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

require 'config/environment'

in my gem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top