Reputation: 28
I'm deploying a Rails app on Heroku and am using the asset pipeline to successfully load my app's JS and CSS from various files.
I have a separate group of JS files, each with static data (mostly coordinates) that are only loaded individually, so I don't want them to be part of the manifest files. For example, if someone visits the "new-york" page, I would load the individual new-york.js, but if someone visits the "chicago" page I load chicago.js.
This works great in development, but on Heroku, that whole directory of files simply doesn't exist. I get 404s, and when I looked in /public/assets at all the precompiled assets, those files are no where to be found.
How do I make these files accessible on Heroku, either by making them show up with the precompiled assets or access them directly from their lib/assets/javascripts home?
Note that I'm already using the Heroku 12 factor gem.
Upvotes: 1
Views: 99
Reputation: 115541
You have to add the folders in the precompile list.
In your application.rb
:
config.assets.precompile += %w(new_york.js) #etc...
Or to get every js files in a folder:
to_precompile = Dir[Rails.root.join("app/assets/javascripts/cities/*.js")].map do |file|
"cities/#{ Pathname.new(file).basename }"
end
config.assets.precompile += to_precompile
Upvotes: 2