Serve Multiple Sites Or Views With A Single Rails Application

Posted By Weston Ganger

I had two blogs that I wanted to combine but main seperate views for each.

There are two main parts to it: Layout and View Paths

For layouts you create two seperate layout files in app/views/layouts

Ex. my_site.html.erb AND my_other_site.html.erb

Next you create the view folders for each site in app/views

Ex. my_site/ AND my_other_site/

# config/routes.rb

constraints'') do
  root to: 'mydomain#index'

# or per route basis

root to: "main#my_action", constraints:'')

root to: 'main#index' # root for all other sites

Related External Links:

Article Topic:Software Development - Ruby / Rails

Date:September 09, 2015