1

I'm developing an enterprise web applications with rails. I'm trying to figure out the best way of using the same models and database between 2-3 rails applications.

My project consists of different applications such as user app, customer app and admin app. All of these 3 will use the same database and almost the same models. I want to create 3 different rails app and deploy them to different servers.

What might be the best way of sharing the models?

4 Answers 4

2

Build one app that contains your models and database. Make all of the controllers return json (or xml). Make no views for this app. Then, create your other apps as so that they make http calls to the first app. This allows you to share the models/database/capabilities of the original app to as many other apps as necessary down the line. And future apps can even use their own or supplemental data stores if necessary, as they are only using the original app as a service.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @KAM, that makes sense. Your solution reminds me the ActiveResource link
0

One of the solutions is to write custom library or gem and put all common code in here.

Comments

0

In your database.yml file for your various projects, just have them point to the same database. Then use the same class names in your various projects.

Comments

0

You can build 4 rails apps. The datastoreapp contains the data model and controllers returns json (no views). The userapp, custapp, adminapp could do api calls to the datastoreapp for consolidated data.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.