Forum: Ruby on Rails 4 Rails apps using the same table. How to streamline?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aa9827db239813ad6c1bd1fcefd2c983?d=identicon&s=25 LaughingNinja (Guest)
on 2009-03-24 17:51
(Received via mailing list)
Hi,

I have 4 apps using similar User tables(3 open source projects and one
in-house app). I'm trying to merge into one shared database User table
(external to all 4 apps).

------------------------------------------------------------------------------------------
I'm using the following code in the User model to switch to the shared
database:

class User < ActiveRecord::Base

  # GSL, 03/18/09 - Add reference to external ua database.
  User.establish_connection (
      :adapter  => "mysql",
      :host     => "example.corp.example.com",
      :username => "root",
      :password => "?",
      :database => "ua_production"
    )
------------------------------------------------------------------------------------------
Then, I have to switch the other models back:
class Attachment < ActiveRecord::Base

  # GSL, 03/18/09 - Add reference to external ua database.
  Attachment.establish_connection (
      :adapter  => "mysql",
      :host     => "example.corp.example.com",
      :username => "root",
      :password => "?",
      :database => "redmine"
    )

------------------------------------------------------------------------------------------
I added the above to all the other models in my Redmine app.

So, now the views that are trying to do a SQL JOIN are bombing.

Is  there an easier way?

Thanks in advance.
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-03-24 18:53
(Received via mailing list)
On Tue, Mar 24, 2009 at 11:50 AM, LaughingNinja
<glackerman@wetdesign.com> wrote:
> So, now the views that are trying to do a SQL JOIN are bombing.
>
> Is  there an easier way?

Are you sure something's not correct with your model relationships?
What do they look like exactly?  What do the errors from the bombing
look like?


--
Greg Donald
http://destiney.com/
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-03-24 19:06
LaughingNinja wrote:
---------------------------
> I added the above to all the other models in my Redmine app.
>
> So, now the views that are trying to do a SQL JOIN are bombing.
>

Are you trying to join tables from different connections/database
instances?
This topic is locked and can not be replied to.