On Fri, Apr 16, 2010 at 12:42 PM, Jeremy Evans <[email protected]> wrote: > On Apr 16, 12:24 pm, Brian Takita <[email protected]> wrote: >> Hello, I'm using Friendly in my Rails application. Currently there is >> one db connection for ActiveRecord and one db connection for Sequel. >> >> I would like my Friendly objects to play nice with my other AR >> objects, specifically when dealing with transactions. >> >> Would it be possible to use the same connection object as ActiveRecord? >> Are there any bridges or apis out there? > > I think this is a bad idea, but it's probably doable: > > connection = > ActiveRecord::Base.connection.instance_variable_get(:@connection) > DB = Sequel.connect('...') > DB.meta_def(:connect){connection} Awesome, thanks. > > This isn't thread safe of course, and it probably has numerous other > problems, but if you want it bad, you get it bad. Yeah, I'll have to see what the implications are. The major problem I'm having right now is Friendly does not play nice with Rails transactional fixtures, and test speed is important to me (and my coworkers). I don't want to start a debate over whether fixtures are good or not. For us, they are good. > > Honestly, just use separate connections for Sequel and AR. You'll > have fewer problems that way. Another reason for this is connection management. We do quite a bit of forking (Nginx Passenger and forked workers). It would be preferable to manage only one connection, or object. I suppose some sort of connection manager object could be set up which integrates with Sequel's connection (and pooling?) and ActiveRecord, however just using the same object seems like the simplest thing for us at this point.
I'll keep you posted on how it turns out. > > Jeremy Thanks, Brian > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
