Daehee Han
Daehee Han

Reputation: 526

sharing models between two rails app

I have two apps - A and B, which do different tasks on the same database.

It occurred to me that when I try to modify model (say x), I have to do the followings.

  1. modify x.rb in app A and run tests.

  2. replace x.rb in B with x.rb in A.

  3. run tests in B and fail.

  4. find errors in B.

  5. apply to A.

Apparently, it sucks. Is there any good practice for this case?

Upvotes: 0

Views: 748

Answers (2)

You can use an engine : http://guides.rubyonrails.org/engines.html

Engine have shared models for your x applications, if you modify one model each application will inherit the change.

In each app, you will add the references in gemfile :

gem 'my_engine', :path => 'engine_path_project'

and you can write test in the dummy application into the engine project.

Upvotes: 0

xdazz
xdazz

Reputation: 160933

Write a gem and share in the two apps.

Upvotes: 1

Related Questions