Thanks a lot for your input, Rodrigo! You got me on the right track.

I eventually fixed the issue by requiring the Rails environment, because 
your solution would not include all the other dependencies, and would cause 
the gem to throw up.

I merely did a require 
'config/environment.rb': 
https://github.com/kennym/annotate-sequel/commit/e41e31180c3e531b1375479e5e9063e2db89e61a#diff-b5a574228d1b84794185e637dd4edf0cR14

On Tuesday, November 12, 2013 10:19:59 AM UTC-3, Rodrigo Rosenfeld Rosas 
wrote:
>
> I don't think there's some kind of convention on how to use Sequel with a 
> Rails application so it's unlikely you'll find any generic way to apply to 
> your gem. Maybe you could check for the existence of Sequel::Model.db or 
> the constant DB. Other than that I don't think there's much more you could 
> do... Maybe searching for an instance of Sequel::Database in the existent 
> objects...
>
> Having said that, I believe people should really call Sequel::Model.db= in 
> any application making use of Sequel Models. Just add a note in the README 
> asking users to do so if they don't do it already. We do it for our Rails 
> app. Also the DB constant is also defined for us.
>
> Hope it helps,
> Rodrigo.
>
> Em domingo, 10 de novembro de 2013 19h54min12s UTC-2, Kenny Meyer escreveu:
>>
>> 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!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to