Manually establishing a connection should work just fine. Just do something
like this in the class you want to use the alternate database:

  url = URI.parse(ENV["HEROKU_POSTGRESQL_RONIN_URL"])
  ActiveRecord::Base.establish_connection( {
      :adapter => url.protocol,
      :host => url.host,
      :user => url.username,
      :password => url.password,
      :database => url.path[1..-1]
  })

In general however, I will caution that this is a dangerous route to head
down, since it makes it difficult to maintain consistency between apps. For
example, when you change the models in one app, it becomes very difficult to
maintain the other. Instead, I'd definitely encourage you to take a more
RESTful approach and establish formal communication channel. This will
likely be like more work now and less pain in the long run if your
application has a long lifespan of active development.

-pvh

On Wed, Nov 24, 2010 at 2:00 AM, Mark Ellul <[email protected]> wrote:

> Thanks for your response Wes.
>
> I need to do is have my Heroku apps with their own database and using
> a different database with the engine
>
> At the moment I am thinking of inheriting all my Engine's Models from
> one abstract model with a establish_connection set to my engine's DB.
> However I am not sure if that will work well with Heroku.
>
> Does anyone know of any better approaches?
>
> On Nov 23, 9:53 pm, Wes Gamble <[email protected]> wrote:
> > Do a search in the Heroku list archives for DATABASE_URL - you can force
> > the value of this to be the same for two applications.
> >
> > Heroku reserves the right to change the DATABASE_URL at any time for one
> > of the apps., so this is not a perfect solution.
> >
> > Wes
> >
> > On 11/23/10 8:16 AM, Mark Ellul wrote:
> >
> >
> >
> >
> >
> >
> >
> > > BUMP.
> >
> > > I need to know this as well, as I am creating a rails engine which
> > > will be used by 2 apps so that data is shared across the two
> > > applications.
> >
> > > What is the best way to do this?
> >
> > > On Nov 6, 4:15 pm, linojon<[email protected]>  wrote:
> > >> Hi, my app needs to access an external database (cloud-accessible
> > >> postgres database) and a local one. Generally the external database is
> > >> accessed via admin pages (and rake tasks) to import data into the
> > >> local database. I've been using the connection_ninja gem for this. Is
> > >> there a way to deploy that database.yml to heroku, or can you
> > >> recommend another way to do this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<heroku%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to