Many-to-many relationships between model using different db

Hello to all
I am finding out ways to set many-to-many relationships between my two
models with each model belonging to a separate database.
for e.g

  1. I have a “User” Model belonging to “database_1”
  2. I have a “Project” Model which belongs to “database_2”

Apparently there is many-to-many relationship between these two models.
Had the Models been belonging to same databases my job would have been
much easier I would either use hbtm or has_many_through associations for
it
but with each models belonging to there respective databases.I kind of
got stuck with it
Any Suggestion

Thank Anyway

Are you able to access both the databases in your single application?.
If so, what connection settings you have?.

Rails L. wrote:

Are you able to access both the databases in your single application?.
If so, what connection settings you have?.

Yes
I have defined
a second database in my database.yml like this
development:
adapter: mysql
encoding: utf8
reconnect: false
database: database_1
pool: 5
username: root
password: root123
host: localhost

database_2:
adapter: mysql
reconnect: true
database: database_2
username: root
password: root123
host: localhost

and i establish my connection for my second database like this
class Project < ActiveRecord::Base
self.establish_connection :database_2
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs