Answer the question
In order to leave comments, you need to log in
How to fix asset display in multisite rails app?
Hello!
I am making a rails application that will serve many sites.
The structure looks like this:
- assets
-- stylesheets
--- site1
--- site2
-- javascripts
--- site1
--- site2
-- images
--- site1
--- site2
-views
-- site1
--- layouts
--- pages
-- site2
--- layout
--- pages
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
layout :determine_site
before_filter :determine_view_path
private
def determine_site
if Rails.env.production?
@site = Site.find_by :domain_production => request.host
@site.code if @site.present?
else
@site = Site.find_by :domain_local => request.host
@site.code if @site.present?
end
end
def determine_view_path
prepend_view_path ["#{Rails.root}/app/views/#{determine_site}"]
end
end
Rails.application.config.assets.precompile += %w( ckeditor/* )
Rails.application.config.assets.precompile += %w( site1/*.css site1/*.js )
Rails.application.config.assets.precompile += %w( site2/*.css site2/*.js )
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question