2017-09-29 306 views
1

當我運行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

你能告訴我們'production.rb'文件嗎? – Cyzanfar

+1

@Cyzanfar我添加了production.rb文件。 – jrocc

回答

0

我想通了,我查看了公共文件夾,並清除了那裏的內容,然後運行rails資源:預編譯,並在文件名的末尾用指紋創建了所有新文件。

我也有config.middleware.insert_before ActionDispatch::Static, Rack::Deflater在我的application.rb我刪除了這一行,並加載了一切。

0

只是改變:

config.serve_static_assets = false 

到:

config.serve_static_files = false 

讓我知道是否有幫助。

+0

嘗試預先編譯更改爲proudction.rb文件時仍出現同樣的錯誤。 – jrocc