Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Rails app, single MySQL database

I intend to have multiple Rails apps each for site.com, api.site.com, admin.site.com. All apps will access the same tables from one single MySQL database. Apps and database runs in the same server.

Is there any settings in Rails, ActiveRecord or MySQL that I need to be concerned about for above access scenerio? Thanks

Running: Rails 2.3.5, MySQL 5.0, Nginx, Passenger, RubyEE

like image 705
Gaius Parx Avatar asked Apr 22 '10 12:04

Gaius Parx


1 Answers

This configuration tends to be quite difficult to maintain. In every app, you would need to keep schema.rb and models in sync in order to use the same database. It means lot of duplication.

This isn't probably a good idea. Instead, you might want to design the application to meet one of the following scenario:

  • one Rails application which handles site.com, api.site.com and admin.site.com (why do you need separate app?)
  • multiple Rails applications, but just one interact with the db. The others uses the main application API (quite complex)
  • different apps with different purposes (for instance, you might want to use Sinatra + Datamapper for api.site.com)

The first option is probably the best one in most cases.

like image 83
Simone Carletti Avatar answered Sep 17 '22 14:09

Simone Carletti