Skip to content

Instantly share code, notes, and snippets.

@elliotthilaire
Created February 21, 2017 13:09
Show Gist options
  • Save elliotthilaire/359543ce30d47d82103b63e1d17f0843 to your computer and use it in GitHub Desktop.
Save elliotthilaire/359543ce30d47d82103b63e1d17f0843 to your computer and use it in GitHub Desktop.
Precompile assets based on controller_path
# http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets
Dir[Rails.root.join('app/controllers/**/*_controller.rb')].each do |path|
controller_path = path.match(/controllers\/(.*)_controller.rb/)[1]
Rails.application.config.assets.precompile += ["#{controller_path}.js", "#{controller_path}.scss"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment