当我运行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
这让我疯狂了两天。任何帮助都是合适的。
答案 0 :(得分:0)
只需改变:
config.serve_static_assets = false
成:
config.serve_static_files = false
如果有帮助,请告诉我。
答案 1 :(得分:0)
我想通了,我查看了公共文件夹并清除了那里的内容,然后运行了rails assets:precompile,并在文件名末尾创建了带有指纹的所有新文件。
我的 application.rb 中也有{{1}}我删除了这一行,所有内容都已加载。