Hishalv
Hishalv

Reputation: 3052

Why does rake assets:precompile in development cause problems but not in my production environement

I have upgraded my app on heroku to a cedar stack so that the asset pipeline works. I have followed the instructions given in heroku's docs by choosing to compile assets locally.

This has created a directory public/assets. Everything in production works perfectly(css, js, with no problems). Going back to my development environment seems to cause the js to not function properly.

In environments/production.rb

config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true

In environments/development.rb

config.assets.compress = false
config.assets.debug = true
config.assets.compile = true

I have checked the source page and all files get loaded correctly with no duplicate entries. I have read some SO questions about whether to compile assets locally or in production but none of them seem to help. Is there something else that i am missing to restore my development javascript code and is this the correct procedure to follow? Thank you

Upvotes: 4

Views: 3595

Answers (1)

Hishalv
Hishalv

Reputation: 3052

Ok i seem to have solved it.

In environments/development.rb change this line

config.assets.debug = true

to this

config.assets.debug = false

Not sure why this works but from reading the rails guides and quote:

"When debug mode is off, Sprockets concatenates and runs the necessary preprocessors on all files. With debug mode turned off the manifest above would generate instead:"

<script src="/assets/application.js" type="text/javascript"></script>

Hope this helps someone with similar issues.

Upvotes: 7

Related Questions