一切都在本地版本上运行,但不适用于Heroku
在生产站点上查看源代码时,我可以看到指向css文件的链接
<link href="/dist/css/example.min.css" rel="stylesheet" type="text/css" />
但是当我单击它时,我得到默认值
“您要查找的页面不存在。您可能输入了错误的地址或页面已移动。”
git status“在分支主机上没有任何内容可提交工作目录清除”
生产环境
Rails.application.configure do
config.cache_classes = true
config.serve_static_assets = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.force_ssl = true
config.log_level = :debug
config.log_tags = [ :request_id ]
config.action_mailer.perform_caching = false
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.active_record.dump_schema_after_migration = false
end
不太确定从哪里开始。 这是单击后呈现错误页面的唯一CSS链接。 所有其他的CSS链接都可以工作。 任何想法,我要去哪里错了?
更新:所以我决定放弃一会儿,休息一下。 回来后,我决定刷新生产环境,在不做任何更改之前,我对备份的“原始”文件副本没有任何更改,以尝试解决此问题,因此工作起来……所以我不知道发生了什么,也许heroku的问题吗? 外星人? 量子力学的磁性反转?
您必须使用asset_path,将CSS文件移动到app / asssets / stylesheets并在application.scss中添加require
如果您不想使用de asset_path,则应将CSS移到公用文件夹。
尝试预编译资产管道。
RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets
git commit -m "vendor compiled assets"
push to github and then heroku