开发者

Want to use 1 rails app for multiple sites/domains

开发者 https://www.devze.com 2022-12-19 08:12 出处:网络
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

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?


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.


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.


I built something specifically for this purpose a few years ago. I haven't touched it in a while, but there's some network activity on github. Rails Multisite Plugin


Paulbonner's response pretty much reflects what I'm thinking myself: if sites would diverge in functionality over time - it would be a nightmare to support later.

So I would probably create several separate Rails applications, but I would use something like Rails Cells to develop functionality, that's common to all websites. Then I would share all my cells across all applications using svn:externals or equivalent from Git.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号