获取资产请求时的Rack :: Lint :: LintError

时间:2015-04-13 16:55:26

标签: ruby-on-rails activeadmin assets rack http-status-code-304

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

步骤:

  1. 转到网站:浏览器加载网站,所有资产都可以
  2. 刷新页面:浏览器使用 If-Modified-Since 标题
  3. 通过 GET 请求检查资产更改
  4. 500
  5. 的服务器响应

    Rack :: Lint :: LintError /assets/active_admin-5e156170588231ea208a6443d45bb66c.css 在304响应中找到Content-Type标头,不允许

    奇怪的是:

    响应包含JS和CSS资产的标题 Content-Type:text / html 。当浏览器在没有If-Modified-Since标头的情况下发出请求时,响应的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)
    

    的Gemfile:

    # 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
    

    有什么想法吗?

    由于

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,使用独​​角兽的宝石unicorn-rails解决了它。