多个Rails应用程序,单个MySQL数据库 [英] Multiple Rails app, single MySQL database

查看:78
本文介绍了多个Rails应用程序,单个MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算为site.com,api.site.com,admin.site.com分别使用多个Rails应用程序.所有应用程序将从一个MySQL数据库访问相同的表.应用程序和数据库在同一服务器上运行.

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.

在上述访问场景中,我需要关注Rails,ActiveRecord或MySQL中的任何设置吗?谢谢

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

运行:Rails 2.3.5,MySQL 5.0,Nginx,Passenger,RubyEE

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

推荐答案

此配置往往很难维护. 在每个应用程序中,您都需要使schema.rb和模型保持同步,以便使用相同的数据库.这意味着很多重复.

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:

  • 一个处理site.com,api.site.com和admin.site.com的Rails应用程序(为什么需要单独的应用程序?)
  • 多个Rails应用程序,但是只有一个与db交互.其他使用主应用程序API(相当复杂)
  • 具有不同用途的不同应用程序(例如,您可能要对api.site.com使用Sinatra + Datamapper)

在大多数情况下,第一个选项可能是最好的.

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

这篇关于多个Rails应用程序,单个MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆