Reputation: 63748
I'm using Heroku to run a Rails app: grafly.herokuapp.com. However, my CSS and JS for the controller aren't being found, while other CSS and JS (precompiled into application) are being found. This only happens on Heroku. Local is fine. What can cause this?
I use controller specific JS and CSS. Here is my in views/layouts/application.html.erb
<head>
<title>Grafly</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= javascript_include_tag params[:controller] %>
</head>
Upvotes: 1
Views: 260
Reputation: 37507
If you're accessing stylesheets and javascripts directly as you are without going through the manifest (application) then you need to explicitly add the assets to your precompile list. In development mode Rails with compile your assets on the fly whilst in production you will get errors.
There's a section in the Rails guides at http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets
You're probably missing
config.assets.precompile += [ '<controllername.js>', '<controllername.css>']
There's a relatively new gem https://github.com/schneems/sprockets_better_errors that will highlight these errors for you in development.
Upvotes: 1