2012-03-27 162 views
8

我有導軌應用程序,它們在本地計算機上工作得很完美。但是,當我在Heroku上部署我得到它在瀏覽器下一個錯誤:加載資源失敗:服務器響應狀態爲404(Not Found)

Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/stylesheets/application.css 
Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/javascripts/application.js 

我在\ JavaScript和\程序\資產\文件夾樣式表的應用程序\資產這個文件。

這裏是我的配置\ production.rb:

# Disable Rails's static asset server (Apache or nginx will already do this) 
config.serve_static_assets = false 

# Compress JavaScripts and CSS 
config.assets.compress = true 

# Don't fallback to assets pipeline if a precompiled asset is missed 
config.assets.compile = true 

# Generate digests for assets URLs 
config.assets.digest = true 

這裏部署的控制檯輸出:

 Using mongoid (2.4.7) 
     Using rails (3.2.1) 
     Using sass (3.1.15) 
     Using sass-rails (3.2.5) 
     Using uglifier (1.2.3) 
     Your bundle is complete! It was installed into ./vendor/bundle 
     Cleaning up the bundler cache. 
-----> Writing config/database.yml to read from DATABASE_URL 
-----> Rails plugin injection 
     Injecting rails_log_stdout 
     Injecting rails3_serve_static_assets 
-----> Discovering process types 
     Procfile declares types  -> (none) 
     Default types for Ruby/Rails -> console, rake, web, worker 
-----> Compiled slug size is 15.8MB 
-----> Launching... done, v24 
     http://hollow-cloud-7412.herokuapp.com deployed to Heroku 

To [email protected]:hollow-cloud-7412.git 
    cb8ded3..dc103ac master -> master 

我怎樣才能解決呢?

回答

17

您應該在生產環境中precompile assets或設置config.assets.compile = true

欲瞭解更多信息,請登錄heroku開發中心,閱讀how to use rails 3.1+ asset pipeline on heroku

+0

我試圖修復它,但沒有成功。我已更新我的問題以提供更多信息。 – demas 2012-03-27 12:42:19

+0

這是否正確?是否在'... herokuapp.com/stylesheets/application.css'文件夾中搜索文件? ('public'文件夾丟失 – demas 2012-03-27 12:44:09

+0

您是否嘗試在實時編譯過程中重新啓動應用程序?它會在'/ public/assets'文件夾中生成文件 – NARKOZ 2012-03-27 13:11:19

0

看起來你似乎是一個運行rails 3.1+的mongoid用戶。這是Mongoid用戶一個相當普遍的問題,因爲文檔指示您在config/application.rb

require 'rails/all' 

要解決此刪除這條線,下面一行添加到config/application.rb

require 'sprocket/railtie' 
相關問題