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.
Generally asset is anything that browser loads after it gets the HTML page. Meaning javascript, css and any images. But as you pointed out there are two different image types in a rails project.
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
Mount within the Rails routes does the equivalent of a Unix mount . It actually tells the app that another application (usually a Rack application) exists on that location. It is used mostly for Rails Engines.
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"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With