当我将我的rails应用程序(在Cloud 9中开发)部署到Heroku时,无法显示背景图像或背景颜色。 (来自css文件)
如何解决这个问题? 我试图预编译资产。最初会显示背景颜色,但不显示背景图片。现在什么都不会显示出来。
Application.css
*{
margin: 0;
padding: 0;
}
body{
background-color: pink;
}
生产环境:
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to
config/initializers/assets.rb
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.serve_static_assets = true
config.active_record.dump_schema_after_migration = false
答案 0 :(得分:0)
我终于找到了解决方法。我想我应该分享它以防其他人遇到同样的问题。请注意,每次运行exec rake asset:precompile(如果你还在Cloud9中)它将导航回到你的根目录。你必须回到你的应用程序才能添加,提交和推送。
参考:Heroku not updating css for rails app
每次对CSS进行更改时,都需要在终端上运行以下命令:
$bundle exec rake assets:precompile
$git add .
$git commit -m "msg"
$git push heroku master