Rails Stylesheets on Heroku

前端 未结 2 865
长情又很酷
长情又很酷 2021-02-20 08:30

On my local machine, when I view my Rails App, my stylesheets are successfully linked at /assets/stylesheets/ but on Heroku, it is changed to /stylesheets/

相关标签:
2条回答
  • 2021-02-20 08:40

    Michael, I before you push to heroku try:

    rake assets:precompile

    This will precompile them in the public folder so that they can be served to Heroku. Let me know if that didn't work.

    Also, make sure the following line exists in config/environments/production.rb

    config.serve_static_assets = true
    

    Then of course

    git push heroku master

    0 讨论(0)
  • 2021-02-20 08:48

    Instead of checking in compiled assets into Git, first read this: https://devcenter.heroku.com/articles/ruby-support#plugin-injection-in-rails-4

    You can either add this gem

    gem 'rails_12factor'

    or add this gem specifically

    rails_serve_static_assets

    or manually change the config in config/environments/production.rb

    config.serve_static_assets = true

    0 讨论(0)
提交回复
热议问题