Ruby on rails Rails Heroku CSS未出现在生产中
所有东西都在本地版本上工作,但在Heroku上没有 当我在生产站点上查看源代码时,我可以看到指向css文件的链接Ruby on rails Rails Heroku CSS未出现在生产中,ruby-on-rails,heroku,Ruby On Rails,Heroku,所有东西都在本地版本上工作,但在Heroku上没有 当我在生产站点上查看源代码时,我可以看到指向css文件的链接 但是当我点击它时,我得到了默认值 “您要查找的页面不存在。您可能键入了错误的地址,或者页面可能已移动。” git状态“在分支主机上无需提交工作目录清理” 生产环境 Rails.application.configure do config.cache_classes = true config.serve_static_assets = true config.eag
但是当我点击它时,我得到了默认值
“您要查找的页面不存在。您可能键入了错误的地址,或者页面可能已移动。”
git状态“在分支主机上无需提交工作目录清理”
生产环境
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链接都可以工作。你知道我哪里出错了吗
更新:所以我决定放弃一段时间,休息一下。回来后,我决定刷新生产环境,在试图修复问题之前,它不会对作为备份的“原始”文件副本进行任何更改。。。所以我不知道发生了什么,也许是希罗库那边出了问题?外星人?量子力学磁反转 您必须使用资产路径,将CSS文件移动到app/assset/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
css文件在它要查找的公共文件夹中,我在
/public/dist/css/example.min.css
中有该文件,它与我的所有其他样式表一起工作,而不是这个。这是rails 5项目吗?然后尝试将config.public\u file\u server.enabled=true添加到config/environments/production.rbyes,但是什么都没起作用,我已经试了差不多两天了。我在谷歌上找到了20多个解决方案,但都没用。在这一点上,重新开始并只处理一个新分支、将更改推送到暂存环境并进行测试将不那么费力。请添加layouts/application.html.erb
,application.css