将Rails应用“连接"到已经存在的MySQL数据库? [英] 'Connect' a rails app to an already existing MySQL DB?

查看:115
本文介绍了将Rails应用“连接"到已经存在的MySQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在我公司中,我们正在慢慢迁移到Rails而不是PHP(准确地说是Code Igniter). 因此,我们实际的PHP应用程序正在使用Mysql数据库,我想将一个新的Rails应用程序连接到该数据库,但是与此同时,我们的PHP仍在运行,因此我无法更改该数据库.

So in my company we are slowly moving to Rails instead of PHP(Code Igniter to be precise). So, our actual PHP App is using a Mysql DB and I'd like to connect a new Rails app to this DB but meanwhile our PHP is still running, so I can't change the DB.

我真的不知道我应该从哪里开始使用所有rails功能(或者至少要尽可能多地使用).

I don't really know where I should start to use all the rails features (Or at least as much as possible).

推荐答案

将Rails应用程序连接到现有数据库应该不会有任何危害.您将需要注意任何与Rails约定不符的事情(例如,表名是多个模型),并更改数据库(和您的php应用程序)或解决Rails中的问题.

There shouldn't be any harm in connecting your rails app to an existing database. You will need to watch for anything that goes against rails conventions (table names are plurals of models, for example) and either change the database (and your php app) or program around the problem in rails.

但是第一步只是连接到数据库并为现有表建立模型,然后查看哪些有效,哪些无效.

But the first step is simply to connect to the database and make models for the existing tables and see what works and what doesn't.

此后,如有任何特定问题,请在此处发布.

After that, post here with any specific problems.

建议,对数据库进行备份,然后针对该数据库开始编程,以构建应用程序,并确保一切安全进行.

As a suggestion, take a backup of your database and start out programming against that to build your application and be sure everything works safely.

这篇关于将Rails应用“连接"到已经存在的MySQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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