Multiple public folders, single rails installation

前端 未结 2 2010
滥情空心
滥情空心 2020-12-19 07:30

I have a rails application I would like to use for multiple sites, each with different designs.

I would like to change the rails installation /public directory to so

相关标签:
2条回答
  • 2020-12-19 08:05

    I know this question is pretty old, but I think I found an answer for this in Rails 4.2.

    You just simply have to put this line in your config/application.rb:

    middleware.use ::ActionDispatch::Static, "#{Rails.root}/another_public_folder_name", index: 'index', headers: config.static_cache_control
    

    This makes all files in /another_public_folder_name to be served by Rails.

    This is the way Rails use to setup the standard /public folder. I found it checking the sources:

    https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ffffd83092718e1/railties/lib/rails/application/default_middleware_stack.rb#L24

    0 讨论(0)
  • 2020-12-19 08:06

    Duh. Just add 2 more rules for stylesheets and javascripts (I guess they get wiped when you change the parent path)

    paths.public.stylesheets = "site_one/stylesheets"
    paths.public.javascripts = "site_one/javascripts"
    
    0 讨论(0)
提交回复
热议问题