Rails 4: assets not loading in production

前端 未结 18 1391
梦如初夏
梦如初夏 2020-11-29 15:15

I\'m trying to put my app into production and image and css asset paths aren\'t working.

Here\'s what I\'m currently doing:

  • Image assets live in /app/a
18条回答
  •  执念已碎
    2020-11-29 16:11

    What you SHOULD NOT do:

    Some of my colleagues above have recommended you to do this:

    config.serve_static_assets = true  ## DON”T DO THIS!! 
    config.public_file_server.enabled = true ## DON”T DO THIS!!
    

    The rails asset pipeline says of the above approach:

    This mode uses more memory, performs more poorly than the default and is not recommended. See here: (http://edgeguides.rubyonrails.org/asset_pipeline.html#live-compilation)

    What you SHOULD do:

    Precompile your assets.

    RAILS_ENV=production rake assets:precompile

    You can probably do that with a rake task.

提交回复
热议问题