资产预编译错误

Assets Precompile Error

当我 运行 rake RAILS_ENV=production assets:precompile --trace 为生产预编译我的资产时,出现此错误。我添加了 production.rb 文件。

Invoke assets:precompile (first_time)
Invoke assets:environment (first_time)
Execute assets:environment
Invoke environment (first_time)
Execute environment
rake aborted! 
No such middleware to insert before: ActionDispatch:Static

production.rb

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.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier


  config.assets.compile = false

  config.server_static_assets = false

  config.log_level = :debug

  config.action_mailer.perform_caching = false

  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

这两天让我发疯了。任何帮助都是适当的。

只需更改:

config.serve_static_assets = false

进入:

config.serve_static_files = false

如果有帮助请告诉我。

我想通了 我查看了 public 文件夹并清除了其中的内容 然后 运行 rails assets:precompile 并且创建了所有新文件文件名末尾有指纹。

我的 application.rb 中也有 config.middleware.insert_before ActionDispatch::Static, Rack::Deflater 我删除了这一行并加载了所有内容。