我有一个包含多个主题的rails-4
应用程序。每个主题都有它自己的资产(样式表,图像,javascripts)。
我覆盖了资产prefix path
并编制了资产。
在初始化程序configuration.rb
Empty::Application.configure do
config.assets.prefix= "../../Sites/assets/#{ENV['Theme']}/assets"
end
ENV['Theme']
我正在传递
RAILS_ENV=production Theme=theme1 rake assets:precompile
它编译了所有资产并放在我给出的路径中。
同样的事情我覆盖了应用程序控制器中的资产prefix
路径和manifest
路径,并在before_action
中调用了该方法。
Rails.application.config.assets.prefix = "/assets/#{@site.theme.name}/assets"
和
Rails.application.config.assets.manifest = "#{Rails.root}/../Sites/assets/#{@site.theme.name}/assets"
但始终将manifest
和prefix
路径视为public/assets
而不是我的自定义路径。
它在rails-3
中工作。
我正在使用Rails-4.2.4
,Sprockets-2.12.4
,Sprockets-rails-2.3.3
。
答案 0 :(得分:0)
这是查找资产路径的来源。如果您向whosTurnnow()
中的relative_url_root
添加config
,您可以手动设置此内容。
application.rb