Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to use 1 rails app for multiple sites/domains

I have a client who needs the same custom CMS developed for about 5 apps. All apps will have a "similar" but different look and feel and I'd really like to have 1 rails application handle this and just modify the layout/views as needed. Is there a gem/plugin or a precedent for this?

like image 752
BandsOnABudget Avatar asked Feb 08 '10 20:02

BandsOnABudget


2 Answers

Doug's suggestion will work if the differences between the sites are purely style and static-content -- e.g., if you're basically just "skinning". But I'd be cautious following that approach if the differences will be more involved than that. You could very easily end up with a maintenance nightmare, with all your business logic surrounded by case statements and lots of special case code spread through your application. And you'd really feel the pain if you ever wanted to separate the sites onto different servers or make significant functional changes to some of the sites but not others.

If you anticipate any significant differences between the sites, you might want to consider developing them as separate Rails projects with shared components. Put the code that they'll share into gems or plugins, and reserve the separate projects for the attributes they don't share. For a small increase in overhead up front, you'd buy yourself a lot more flexibility down the road.

like image 181
paulbonner Avatar answered Nov 07 '22 10:11

paulbonner


You could start with DHH's Account Location plugin as a start, but modify it to use the Top Level Domain name (TLD) instead of a subdomain. Its a very simple library, but it gets the job done. Just be sure to scope all your finds in your app by the Account associated with the domain name.

like image 42
Doug Neiner Avatar answered Nov 07 '22 10:11

Doug Neiner