#using instance method?

20 views
Skip to first unread message

Josh Bielick

unread,
Mar 26, 2015, 2:20:37 PM3/26/15
to octopus-ac...@googlegroups.com
Using Rails 4.2.0, seems that some things have changed such as ActiveRecord#connection instance method has been deprecated. So I've forked the repo and begun playing around with a `using` instance method. It's currently contained in Octopus::Model::ShardMethods and thus, becomes a class and instance method. 

What I'm having trouble with is how that model instance is keeping track of the shard to use. When setting `instance.current_shard`, it seems to have no affect when performing subsequent query / persistence methods from that instance. How should the current shard be changed for a instance? Ideally, I'd be able to retrieve instances from the read-only shard such as `User.using(:slave).where(...)` and later be able to update the returned models `user.using(:master).update_attribute(...` but the instance method `.using` has no effect and the write operation is attempted on the :slave shard. 

I don't see any specs or mention of the .using instance method so my question is should it work? And if not, should the `using` method be moved to ClassMethods and not shared?
Reply all
Reply to author
Forward
0 new messages