Reputation: 2105
How can I add vendor/assets/javascripts/mymountableengine
or vendor/assets/stylesheets/mymountableengine
to my mountable engine's assets paths? I want to be able to require files from these folders in my mountable engine's application.js/application.css file with sprockets.
Rails 3.2.2
Thanks.
Upvotes: 12
Views: 10254
Reputation: 5116
I do like this:
module MyEngine
class Engine < ::Rails::Engine
config.assets.paths << File.expand_path("../../assets/stylesheets", __FILE__)
config.assets.paths << File.expand_path("../../assets/javascripts", __FILE__)
config.assets.precompile += %w( my_engine.css )
end
end
Upvotes: 8
Reputation: 2105
Turns out they were already loaded! Just put them in the wrong directory: engine/vendor/assets/javascripts/engine
- putting them in engine/vendor/assets/javascripts
made them requireable. For others, just check Rails.application.config.assets.paths
to see which paths are loaded, I believe engines use the parents Sprockets environment, so to add paths just use Rails.application.config.assets.paths << "path/here"
Upvotes: 9