Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add folder to asset pipeline 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.

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

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?

like image 328
agmcleod Avatar asked Feb 06 '13 17:02

agmcleod


1 Answers

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"
like image 109
agmcleod Avatar answered Sep 22 '22 15:09

agmcleod