这是 Heroku 生产的页面源标题:
<head>
<title>Gosgf</title>
<link data-turbolinks-track="true" href="/assets/application-e11c07d8fd96415a6de17e941d115bde.css" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/application-786dea1c8b4a7b9d1635fb121196a3f3.js"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="LAzUNgZEUmay9OLVUsN0u6Amz/9BVJngJKvE+B6+L1g=" name="csrf-token" />
</head>
这是来自 127.0.0.1:3000
<head>
<title>Gosgf</title>
<link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/games.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/jgo/jgoboard.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/jgo/jgoboard_small.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/sgfs.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/welcome.css?body=1" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/games.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/all-min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/autodiv.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/jgoboard.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jgo/sgf.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery-1.10.1.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery-1.10.1.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery/jquery.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/sgfs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/welcome.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/application.js?body=1"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="8+ZHwU8R9V/V5zgoVL3fqyGKxYG2BxV2f8LtRCZNDAg=" name="csrf-token" />
</head>
Heroku 忽略了很多js
和css
以下。app/asserts
我已经添加了:
gem 'rails_12factor', group: :production
在宝石文件中。
资产是预编译的:
RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "compiled assets"
之前push
。
在config/environments/production.rb
:
config.serve_static_assets = true
config.assets.compile = true
我如何告诉 Heroku 加载js
和css
资产?