Reputation:
I have both .js
and .coffee
files in my /app/assets/javascripts/
folder. The .coffee
files will not run unless I call rake assets:precompile
, which is a pain because I have to do rake assets:clean
and precompile them again whenever I make a change.
Also, the precompiled .js file is included in addition to the source files, which causes double event handlers and all that good stuff.
My understanding is that the coffeescript should be compiled to javascript upon each request if it's not precompiled, but it doesn't seem to be doing so. I can't find the compiled script loading in Firebug, and I don't see its behavior, at least.
My /config/application.rb
has the following line configured:
# Enable the asset pipeline
config.assets.enabled = true
What else is there to check?
I am using Rails 3.2.3.
Upvotes: 1
Views: 1495
Reputation: 14943
If you precompile on your local machine, then you can commit these generated assets into the repository and proceed with deployment. No need to compile them on production machine.
But it introduces a problem: now when you change source files (coffescript / scss), the app won't pick up the changes, because it will serve precompiled files instead. rake assets:clean deletes these precompiled files.
What I usually do if I want the assets to precompile on the production server to pickup the new changes every build is just clean the assets - once of course unless you re-precompile them
rake assets:clean
When the changes are made and you don't want to precompile them every build do
rake assets:clean
rake assets:precompile
Upvotes: 3