nbudin / heroku_external_db

Makes it easy to connect to external databases from a Heroku app
MIT License
40 stars 5 forks source link

How to use this gem for rails2.3.11 version #10

Closed vardhan-nyros closed 12 years ago

vardhan-nyros commented 12 years ago

I have copied the initialiser from the gem to my application then how can I use this gem in heroku to connect to another heroku application Database. Is this be possible with this gem.

Thanks, Sai

nbudin commented 12 years ago

That is possible only if the other application's database allows ingress (and if that's the case, you may not need this gem). Which database plan is the other app using?

vardhan-nyros commented 12 years ago

Hi,

Thanks for the quick reply. My requirement is that I have two apps in heroku (app1 & app2) as such the app2 is upgraded version of app1 with increased requirements.So, I need to switch users from app1 to app2 depending upon the users choice (switch new(old)) simultaneously.

Is this be possible with this gem or do we have any other alternative. Kindly suggest me as I am a new bee to rails.

Thanks, Sai

vardhan-nyros commented 12 years ago

Both the applications use the shared databases and the application resides in heroku.So, they use postgres DB

nbudin commented 12 years ago

Heroku's shared database plan doesn't support ingress. I recommend you look into the Dev or Crane database plan, both of which support external connections.

You can certainly do what you're suggesting in Rails, although I don't know if this gem is necessary for it. I would recommend that you familiarize yourself with ActiveRecord's establish_connection method and how it works, and how it can be used to connect to multiple databases from the same app. This may be sufficient for your needs. It is actually what this gem uses.

There are only two advantages to using my gem:

  1. It automatically parses Heroku-style database URLs and converts them to ActiveRecord connection parameters on startup, and
  2. It allows you to use MySQL over SSL, which is normally impossible on Heroku.

Obviously the MySQL piece is not relevant for your needs because you are using Postgres. So I would definitely recommend you check out establish_connection and see if you can accomplish what you need through that. This gem won't help you all that much with your use case.

vardhan-nyros commented 12 years ago

ok. Thanks for your support nbudin. So, I need to check with the Crane database plan as you suggested.

Thanks, Sai