将文件夹添加到资产管道路径? [英] Add folder to asset pipeline path?

查看:59
本文介绍了将文件夹添加到资产管道路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个我最近从Rails 3.0更新到Rails 3.2的Rails应用程序.该应用程序为多个客户端提供服务.要为每个客户端自定义它,我们有目录app/themes.在其中有子模块.每个子模块都包含locales/en.ymlviews/layoutsviews/controller_name等内容.我们使用prepend_view_path添加主题视图,并使用I18n.load_path添加区域设置.我们正在考虑使用资产管道,以便将所有客户资料的混合都排除在公共目录之外,并将其包含在每个主题中.

We have a rails app that I recently updated from Rails 3.0 to Rails 3.2. This app services multiple clients. To customize it for each client, we have the directory app/themes. In there are submodules. Each submodule contains things like locales/en.yml, views/layouts, views/controller_name, etc. We use the prepend_view_path to add the theme views, and the I18n.load_path to add in the locales. We're looking at using the asset pipeline so we can keep all the mix of client material out of the public directory, and keep it contained in each theme.

有没有一种方法可以动态告诉Rails加载我想要的主题/主题名称/资产文件夹?我们使用设置逻辑来设置哪个主题处于活动状态.因此,如果我将主题设置为"google",则ApplicationController然后从路径加载文件:

Is there a way i can dynamically tell rails to load which theme/theme-name/assets folder i want? We use settings logic to set which theme is active. So if i have the theme set to "google", the ApplicationController then loads files from the path:

app/themes/google/locales/*.yml
app/themes/google/views

我想做的就是拥有清单文件,

What I'd like to be able to do is have the manifest file,

app/themes/google/assets/stylesheets/application.css

易于访问布局,就像在app/views/layouts文件中一样:

easily accessible to the layout, much like you would in an app/views/layouts file:

= stylesheet_link_tag "application"

有没有办法做到这一点?还是我们需要手动将资产移动到实际资产目录中?

Is there a way i can do this? or do we need to manually move the assets into the actual assets directory?

推荐答案

能够在应用程序中完成.rb:

Was able to do it in the application.rb:

require "#{Rails.root}/app/models/settings.rb"
config.assets.paths << "#{Rails.root}/app/themes/#{Settings.theme}/assets/stylesheets"
config.assets.paths << "#{Rails.root}/app/themes/#{Settings.theme}/assets/images"
config.assets.paths << "#{Rails.root}/app/themes/#{Settings.theme}/assets/javascripts"

这篇关于将文件夹添加到资产管道路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆