Reputation: 4908
We have two websites built on top of the same data. Their designs (and data presentation) are totally different, but the underlying data is the same.
Both have their own top level domain.
What is the best way to structure this? Have 2 different rails apps? or two sets of views?
I have thought about a rails engine, but, they will only share models, not views and controllers, so I am not sure if this is the best approach.
Suggestions, article links, etc most welcomed!
Upvotes: 2
Views: 684
Reputation: 87210
Depends if you need to access all the data in both applications, or just specific parts.
I don't think that duplicating your code between two applications is a wise thing to do. If you're presenting the data totally differently, you might need to access it differently. For example on a mobile site you might be loading only from one table, while on a regular webpage you will be loading from 5 tables at once.
Having two applications will give you much more flexibility, than having to share some code. But this of course depends on the size of the app. For 10 models I wouldn't really care about having something duplicate in two apps, but for 150 models it's a completely different story.
Upvotes: 2
Reputation: 14268
We have several apps that use shared databases at Aframe with a set of shared models.
Try something like this structure:
app_one
rails app structure
...
app_two
rails app structure
...
shared
models
Then in each of the apps, you include everything in the shared shared/models directory.
Configure both apps to have the same database details.
This means you can write tests that touch both apps.
Upvotes: 2