Y
Y
Yuri2017-07-22 20:11:39
Ruby on Rails
Yuri, 2017-07-22 20:11:39

Is it possible to use multiple templates for different domains in RoR, but in one project?

Good day!
There is an application on RoR, you need to make sure that the appearance (interface and styles) are different on different domains (but on the same server). Can this be done without making copies of the app just to replace styles and html ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
copyhold, 2017-07-22
@Winter_Silence

Searching for "rails themes" gave this
https://github.com/chamnap/themes_on_rails

N
N. Bekseitov, 2017-07-24
@nbekseitov

The easiest way is to create separate layouts and show this or that layout depending on the condition:

class ApplicationController < ActionController::Base
  layout :fetch_layout

  private

  def fetch_layout
    if request.domain == 'mysite.com'
      'mysite'
    else
      'application'
    end
  end
end

Next, just create mysite.css, mysite.js and mysite.html.erb files

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question