【问题标题】:CSS not loading in my Rails 4 appCSS 没有加载到我的 Rails 4 应用程序中
【发布时间】:2017-11-04 02:55:00
【问题描述】:

在我彻底检查了整个前端设计之后,我的应用程序一切正常。我试图推送到 heroku 上的暂存服务器,但在预编译我的资产时遇到了问题。所以,我尝试了rake assets:clobber && rake assets:precompile,现在根本没有任何 CSS 加载到开发中。我的application.sass 中的语法错误会显示错误页面,但它没有在我的应用程序中加载任何 css。在 chrome 开发工具中,唯一显示的 css 文件是 SweetAlert css 文件。

【问题讨论】:

  • 您是否为 heroku 添加了 12_factor gem?此外,运行“bundle exec rake assets:precompile RAILS_ENV=production”,以便它使用您的生产环境。编译时配置。

标签: ruby-on-rails ruby-on-rails-4 assets


【解决方案1】:

我找到了答案。我以为你必须在开发中预编译你的资产,但经过一些研究我发现你不需要。我用rake assets:clobber 破坏了我的资产,我的css 又开始正常加载了。此外,当推送到 heroku 时,我什么也没做,因为 heroku 在部署时预编译了您的资产

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 2017-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多