0

in my app/assets/javascripts/specific.js I have

//= require_tree ./specific

in app/assets/javascripts/specific/chat I have pusher.js

Also, in config/environments/production I have

config.assets.precompile += %w( specific.js some_other_manifest.js )

However, when I go into production (on heroku) it still complains pusher.js is not precompiled. What am I doing wrong here?

While the application is deployed, the javascript files seem to be compiled.

from Heroku logs:

   Compiled specific/chat/pusher.js  (0ms)  (pid 1042)
   Compiled specific.js  (60ms)  (pid 1042)

But when I go to the view,

 ActionView::Template::Error (specific/chat/pusher.js isn't precompiled):
     1: <%= javascript_include_tag 'specific/chat/pusher' %>
     2: <%= javascript_include_tag params[:controller] %>
     3: 
     4: <div id="chat-header">
   app/views/messages/index.html.erb:1:in `_app_views_messages_index_html_erb___3285714722884343394_70246542189040'

I also tried putting config.assets.precompile .. option inside config/application.rb instead of production.rb

Related: Assets say "not precompiled" when they are precompiled

When I run assets:precompile and look in public/assets folder, I see that they are all precompiled (e.g. specific-bfgbfbf4534535.js)

So the asset is actually precompiled, but the error says it isn't precompiled

From my view:

<%= javascript_include_tag 'specific/chat/pusher.js' %>

Community
  • 1
  • 1
Maximus S
  • 10,759
  • 19
  • 75
  • 154
  • I've never used Heroku so I don't know if there's something Heroku-specific going on here. In your application.html.erb, do you have a line `javascript_include_tag 'specific.js'`? – Paul Richter Jun 11 '13 at 23:02
  • It's not supposed to be included in application.html.erb – Maximus S Jun 11 '13 at 23:30

2 Answers2

2

You don't include specific files, you include the entire manifest, that's the whole point of manifests.

This can't work:

<%= javascript_include_tag 'specific/chat/pusher' %>

Instead, you need a single include for the top-level manifest:

<%= javascript_include_tag 'specifics' %>

From your comment below your question:

It's not supposed to be included in application.html.erb

That isn't how precompiled assets work. You need to include specifics.js, or build another (more granular) manifest. The point of manifests is that they produce a single minified blob of code to be included. You specifically say you see a specific-bfgbfbf4534535.js in your compiled assets folder; that is the file that will be included, and it contains pusher.js.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • WOW. Your answer clarified the last bit that I was missing to understand. Then when I do `javascript_include_tag params[:controller]`, does the app actually load the specific part contained within `application.js` instead of looking at `some_controller.js.coffee` ? – Maximus S Jun 12 '13 at 02:36
  • 1
    Err, no. You should never do `javascript_include_tag params[:controller]`, unless you've set up manifests for each controller. It definitely doesn't load any specific *part* of `application.js`; it loads **all** of `application.js`, every time. It's up to you to code your JavaScript so that this works, and your scripts don't clobber each other. – user229044 Jun 12 '13 at 02:36
  • That sounds more logical. Then what's the purpose of keeping all the automatically-generated js.coffee files that relate to each controller? – Maximus S Jun 12 '13 at 02:39
  • @MaximusS You don't *have* to keep them, it's just meant to be an organizational aide. – user229044 Jun 12 '13 at 02:40
0

try to precompile all assets:

config.assets.precompile += %w( *.css *.js )
Eru
  • 675
  • 4
  • 8
  • Thanks for your input Eru, but this does not solve the problem. (I tried this to solve other issues before) – Maximus S Jun 11 '13 at 23:30