2017-08-17 92 views
0

我在生產服務器上執行了'rake assets:precompile',資產是在公共/資產文件夾中生成的,但rails使用url搜索資源,例如domain.com/javascript/application.js,爲什麼不能像domain.com/assets/application .js,因爲asssets存在於資產文件夾中。當我在生產環境中部署應用程序時,無法找到404錯誤的資產。另外,爲什麼.sprocket-manifest文件不是在資產文件夾中創建的。爲什麼網站資產不包含資產詞?

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.serve_static_files = true # ENV['RAILS_SERVE_STATIC_FILES'].present? 

    config.assets.js_compressor = :uglifier 

    config.assets.compile = false 

    config.assets.digest = true 

    config.log_level = :debug 

    config.i18n.fallbacks = true 

    config.active_support.deprecation = :notify 

    config.log_formatter = ::Logger::Formatter.new 

    config.active_record.dump_schema_after_migration = false 
end 

我一直在使用的軌道4.2.8被 - :像

production.rb有配置。謝謝。

回答

1

在軌道4,你需要做以下修改:

config.assets.compile =真 config.assets.precompile = [ '的.js', '的.css',' *的.css .erb']

這適用於我。使用下面的命令來預編譯資產

RAILS_ENV =產品包的exec耙資產:預編譯

祝您好運!