部署到heroku时,CSS和JS没有显示在我的HEAD中

时间:2014-04-14 11:23:36

标签: ruby-on-rails git heroku

在我将所有更改推送到github之后,我刚刚将项目部署到了​​heroku。一切都很好,除了我注意到一些更新的新css没有通过。 css文件肯定已经提交并推送到github,所以我知道这不是问题。

在heroku应用程序上查看源代码时,我注意到它缺少head部分中的大多数.css和.js文件。有没有理由在heroku上的头部与我在当地的头部不同。一切都运行顺利,自从我上次推送到heroku后,我没有更改任何配置文件......

感谢。

以下是github项目的链接:https://github.com/michaelnavarro/careerfoundry

application.js:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

application.css

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require_tree .
 */

/*

 */

2 个答案:

答案 0 :(得分:2)

您应该预先编译资产:

RAILS_ENV=production bundle exec rake assets:precompile

然后将文件添加到git

git add .
git commit -m "compiled assests"

然后推送到Heroku。 Heroku的资产编译器非常挑剔,并且不会一直工作。你应该在本地做,把所有东西都推到Heroku。

答案 1 :(得分:0)

我注意到CSS文件具有SCSS扩展名。尝试将它们重命名为.css。

此外,您的页面特定的javascript文件为空,因此不会包含任何内容。