Running multiple sites from the same rails codebase?

前端 未结 4 790
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 07:40

I have a client that wants to take their Rails app that has been successful in one niche and apply it to another similar niche. This new instance of the app is going to start ou

4条回答
  •  礼貌的吻别
    2021-01-30 08:14

    With minimal touching of the main site, it might be possible to use the Ruby code from it while extending the templates and changing the styles. I have worked on that extensively in Django and the layout can look like:

    project/
        sites/
            site_one/
                templates/
                models.py
                settings.py
                urls.py
                views.py
            site_two/
                templates/
                models.py
                settings.py
                urls.py
                views.py
        base_app/
        settings.py
    

    You could try do something similar in Rails:

    main_webapp/
        app/
        config/
        ...
        sites/
            site_one/
                controllers/
                models/
                views/
            site_two/
                controllers/
                models/
                views/
    

    Assuming the functionalities are identical across sites but they just have different layout and styles, there will be none or very little model and controller code. Should you wish to add more functionality to specific sites, just stick the code under the desired site folder.

    Django also have the concept of Sites and the ability to look for templates in one specific project folder and an app folder. You could try to copy those features and bring them over to Rails to achieve running multiple site from one codebase.

    I recognize that you are looking for a Rails solution but you can still checkout how it's done in Django and copy some of the useful features to the other side. If I like a Rails specific feature, I'll port it other to Django/Python.

提交回复
热议问题