gpt4 book ai didi

ruby-on-rails - Rack::Lint::LintError 获取 Assets 请求

转载 作者:行者123 更新时间:2023-12-02 03:27:35 31 4
gpt4 key购买 nike

我在生产中遇到了奇怪的问题(我无法在开发模式下重现)。

步骤:

  1. 转到站点:浏览器加载站点,所有 Assets 都可以
  2. 刷新页面:浏览器通过带有 If-Modified-Since header 的 GET 请求检查 Assets 变化
  3. 服务器响应 500

Rack::Lint::LintError 在/assets/active_admin-5e156170588231ea208a6443d45bb66c.css在 304 响应中发现 Content-Type header ,不允许

有些奇怪:

响应包含 JS 和 CSS 资源的 header Content-Type:text/html。当浏览器发出没有 If-Modified-Since header 的请求时,响应的 Content-Type 是正确的。

堆栈跟踪:

/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in assert raise LintError, message...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in block in check_content_type assert("Content-Type header found in #{status} response, not allowed") {...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in each headers.each { |key, value|...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in check_content_type headers.each { |key, value|...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in _call check_content_type status, headers...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/lint.rb: in call dup._call(env)...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/showexceptions.rb: in call @app.call(env)...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/commonlogger.rb: in call status, header, body = @app.call(env)...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/chunked.rb: in call status, headers, body = @app.call(env)...
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/content_length.rb: in call status, headers, body = @app.call(env)...
/usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb: in process_client status, headers, body = @app.call(env = @request.read(client))...
/usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb: in worker_loop process_client(client)...
/usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb: in spawn_missing_workers worker_loop(worker)...
/usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb: in start spawn_missing_workers...
/usr/local/lib/ruby/gems/2.1.0/gems/unicorn-4.8.3/bin/unicorn: in <top (required)> Unicorn::HttpServer.new(app, options).start.join...
/usr/local/bin/unicorn: in load load Gem.bin_path('unicorn', 'unicorn', version)...
/usr/local/bin/unicorn: in <main> load Gem.bin_path('unicorn', 'unicorn', version)

gem 文件:

# Rails

gem 'rails', '~> 4.2.1'
gem 'active_model_serializers', '~> 0.9.3'

# Server

gem 'unicorn', '~> 4.8.3'

# Views and Assets engines

gem 'sass-rails', '~> 5.0.1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'chosen-rails', '~> 1.3.0'
gem 'therubyracer', '~> 0.12.1', platform: :ruby

# ActiveAdmin

gem 'activeadmin', github: 'activeadmin/activeadmin', branch: :master, ref: '7aef260921d418d904d2dba9b1a97eed893e9019'
gem 'status_tag_for'

# Authentication

gem 'devise', '~> 3.4.1'

# Settings

gem 'settingslogic', '~> 2.0.9'

# Database

gem 'pg', '~> 0.18.1'

# Other

gem 'semantic', '~> 1.4.0'

group :test, :development do
# Spec
gem 'rspec', '~> 3.2.0', require: false
gem 'rspec-rails', '~> 3.2.0', require: false

# Quiet Assets
gem 'quiet_assets', '~> 1.0.3'

# OSS licenses management
# without require: false breaks AR see: https://github.com/rails/arel/issues/133
gem 'license_finder', require: false
end

group :test do
# Mocks
gem 'vcr', '~> 2.9', require: false
gem 'webmock', '~> 1.17', require: false
gem 'factory_girl_rails', '~> 4.5.0'

gem 'database_cleaner', '~> 1.3.0'

# Coverage
gem 'simplecov', '~> 0.9.1', require: false
gem 'simplecov-teamcity-summary', '~> 0.1.1', require: false
end

有什么想法吗?

谢谢

最佳答案

我遇到了同样的问题,使用 gem unicorn-rails over unicorn 解决了它。

关于ruby-on-rails - Rack::Lint::LintError 获取 Assets 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29610852/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com