Support for multiple database connections
Closed this issue · 2 comments
hughevans commented
Hiya, awesome looking gem. How hard do you think it would be to support multiple remotes? Our app connects to a bunch of databases:
class OtherModel < ActiveRecord::Base
establish_connection 'other_database'
end
jorgemanrubia commented
Hi,
It should be easy enough. The connection is set to the constant 'remote'
in this line.
You could add an option remote_connections
that would be used when an entry is introduced:
Forceps.configure remote_connections: {
Invoice => 'some_database',
...
}
Now, instead of using 'remote'
directly, it would first try to locate a specific remote database in the options for any given class.
Would that work for you?
I would be willing to merge that PR if you want to work on that.
hughevans commented
Thanks, that’s great. I’ll send through the PR when done.