Reputation: 63567
In my Rails app I have css and js that is unique to each action.
So users#new has its own css. It's named users_new.css.scss
.
I deployed my app to Heroku, and Heroku isn't loading any of the assets. You can see the errors here. How do I fix this so Heroku correctly precompiles and loads the assets?
I read through Heroku's docs on using the asset pipeline, but didn't see any solution.
Upvotes: 0
Views: 206
Reputation: 76774
Precompilation
The problem is your timelines_index.js
is not precompiled:
The way you can tell this is a problem is that when you call the asset in your layout
(which I presume you're doing with the correct path helpers), Rails will automatically reference the latest precompiled version of that file (hence why application.js
has the appended MD5 fingerprint)
I believe you'll need to add your custom files to your precompiled_assets
array:
#config/environments/production.rb
Rails.application.config.assets.precompile += ['timelines_index.js']
This will give Rails the ability to precompile those assets individually, allowing you to call them in your layout:
#app/views/layouts/application.html.erb
<%= javascript_include_tag "timelines_index" %>
This will have to be done for all the custom asset files you wish to call in your layout.
As mentioned by Anil
, you may wish to use the manifest
system of Rails to concatenate all your asset files into their respective application
files.
This will quash the need to append the files to the Rails precompile
array, allowing you to call a single file for your various assets:
#app/assets/javascripts/application.js
//= require_tree .
Upvotes: 1