ClosureTree/closure_tree

How to connect to a separate db?

shawn-zhuxy opened this issue · 5 comments

Hi all;

I have found a same question in gitter but it did not be answered. So I have to ask again here.

I have a rails application that makes a connection to the different databases.
The model is like this:

# Bar Service
class Billing
   connects_to database: { writing: :foo_service, reading: :foo_service}
   has_closure_tree
end

Fetching records in Bar Service works fine. However, when I try to create an object it fails with: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "billing_hierarchies" does not exist.

I create billing_hierarchies in foo service, and I do not hope to create billing_hierarchies in bar service.
So is it a clean way to connect the closure tree to a separate db?

Thank you.

This is an intersting bug. I will work a fix in the day.

Basically the hierarchy table should inherit the connection from the base table.

Thanks for such a quick reply!

@seuros I have made some changes to the code for this issue. PTAL. Thank you. #384 The pr's author @shawndodo is myself.

@shawn-zhuxy , i will push a pre-release today.

@shawn-zhuxy , i will push a pre-release today.

Thank you!