Rails App Not Serving Assets in Production Environment

前端 未结 8 1973
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 01:29

My app works fine when run in development environment. In production (rails server -e production), the browser can\'t access the css and js files and on the con

8条回答
  •  执笔经年
    2020-12-01 01:48

    This sounds like to the problem I was having.

    I found a blog that suggests this is a bug in the Rails 4.0.0 asset pipeline, and is inexplicably mitigated by setting...

    config.assets.compile = true
    

    ... in config/environments/production.rb

    Aside from somehow kicking the asset pipeline in to actually working, that setting will turn on live-compilation of assets. That is normally a bad thing for performance in production, but if you still manually precompile assets when you deploy, with

    rake assets:precompile
    

    ... the live-compilation should never happen (because the necessary assets have already been precompiled).

    I hope this helps :)

提交回复
热议问题