2012-01-14 80 views
4

我在Heroku上安裝了幾個基本的應用程序,沒有問題,而且這個(Rails 3.1.3)看起來很好因爲它顯示的Rails歡迎頁面Heroku上的Rails 3.1.3 :(沒有路由匹配[GET]「/assets/rails.png」)

public/index.html.erb 

但是當我刪除的頁面,然後設置

root :to => 'users#index' 

我有一個問題。在heroku日誌中表示存在路由錯誤

ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 

有沒有人知道這是關於什麼的?

2012-01-14T21:48:29+00:00 heroku[web.1]: Process exited 
2012-01-14T21:48:33+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious) 
2012-01-14T21:48:33+00:00 app[web.1]: >> Maximum connections set to 1024 
2012-01-14T21:48:33+00:00 app[web.1]: >> Listening on 0.0.0.0:32570, CTRL+C to stop 
2012-01-14T21:48:34+00:00 heroku[web.1]: State changed from starting to up 
2012-01-14T21:48:35+00:00 app[web.1]: cache: [GET /] miss 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:48:36 -0800 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: 
2012-01-14T21:48:36+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:48:35+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=19ms status=200 bytes=5907 
2012-01-14T21:48:36+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=30ms status=404 bytes=728 
2012-01-14T21:48:46+00:00 app[web.1]: cache: [GET /] miss 
2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:48:46 -0800 
2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: ActionC 

2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: 
2012-01-14T21:48:46+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:48:46+00:00 app[web.1]: cache: [GET /favicon.ico] miss 
2012-01-14T21:48:46+00:00 heroku[router]: GET mmcarrier.heroku.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=0 
2012-01-14T21:48:46+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=6ms status=200 bytes=5907 
2012-01-14T21:48:46+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=4ms status=404 bytes=728 
2012-01-14T21:48:59+00:00 app[web.1]: cache: [GET /] miss 
2012-01-14T21:48:59+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=5ms status=200 bytes=5907 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:48:59 -0800 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: 
2012-01-14T21:48:59+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:48:59+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=3ms status=404 bytes=728 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:49:18 -0800 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: 
2012-01-14T21:49:18+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:49:18+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=4ms status=404 bytes=728 
2012-01-14T21:49:33+00:00 app[web.1]: cache: [GET /] miss 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:33+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:49:33 -0800 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:33+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:33+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:49:33+00:00 app[web.1]: 
2012-01-14T21:49:34+00:00 app[web.1]: cache: [GET /favicon.ico] miss 
2012-01-14T21:49:33+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=6ms status=200 bytes=5907 
2012-01-14T21:49:33+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=4ms status=404 bytes=728 
2012-01-14T21:49:34+00:00 heroku[router]: GET mmcarrier.heroku.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=0 
2012-01-14T21:50:21+00:00 app[web.1]: cache: [GET /] miss 
2012-01-14T21:50:21+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=4ms status=200 bytes=5907 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:50:21+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=4ms status=404 bytes=728 
2012-01-14T21:50:21+00:00 app[web.1]: Started GET "/assets/rails.png" for 216.251.147.10 at 2012-01-14 13:50:21 -0800 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:50:21+00:00 app[web.1]: cache: [GET /assets/rails.png] miss 
2012-01-14T21:50:21+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:50:21+00:00 app[web.1]: 
2012-01-14T21:52:42+00:00 heroku[slugc]: Slug compilation started 
2012-01-14T21:52:54+00:00 heroku[api]: Deploy 983a24d by [email protected] 
2012-01-14T21:52:54+00:00 heroku[api]: Release v8 created by [email protected] 
2012-01-14T21:52:54+00:00 heroku[web.1]: State changed from up to bouncing 
2012-01-14T21:52:54+00:00 heroku[web.1]: State changed from bouncing to created 
2012-01-14T21:52:54+00:00 heroku[web.1]: State changed from created to starting 
2012-01-14T21:52:55+00:00 heroku[slugc]: Slug compilation finished 
2012-01-14T21:53:01+00:00 heroku[web.1]: State changed from starting to up 
2012-01-14T21:53:05+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=37ms status=404 bytes=728 
2012-01-14T21:53:17+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=5ms status=404 bytes=728 
2012-01-14T21:53:36+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=2ms status=404 bytes=728 
2012-01-14T21:53:38+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=107ms status=500 bytes=728 
2012-01-14T21:53:40+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=20ms status=500 bytes=728 
2012-01-14T21:53:49+00:00 heroku[run.1]: State changed from created to starting 
2012-01-14T21:53:52+00:00 heroku[run.1]: State changed from starting to up 
2012-01-14T21:53:57+00:00 heroku[run.1]: State changed from up to complete 
2012-01-14T21:53:57+00:00 heroku[run.1]: Process exited 
2012-01-14T21:55:15+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=35ms status=404 bytes=728 
2012-01-14T21:55:17+00:00 heroku[router]: GET mmcarrier.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=3ms status=404 bytes=728 
2012-01-14T21:55:22+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=12ms status=500 bytes=728 
2012-01-14T21:56:18+00:00 heroku[router]: GET mmcarrier.heroku.com/ dyno=web.1 queue=0 wait=0ms service=12ms status=500 bytes=728 

回答

9

它看起來像你可能沒有預編譯你的資產,你被推到Heroku的前,嘗試:

rake assets:precompile 
git add . 
etc etc 

我覺得應該幫助。欲瞭解更多信息,請參見這裏:http://devcenter.heroku.com/articles/rails31_heroku_cedar

+0

你是對的,我沒有,我會做,但爲什麼Rails歡迎頁面工作? – Leahcim 2012-01-14 22:14:41

+1

它的工作原理是,歡迎頁面沒有必要的資源。所有樣式都包含在public/index.html文件中,並且不需要任何JavaScript或圖像。很高興我能幫上忙! – 2012-01-14 22:18:21

+0

簡單,它不是資產,它是視圖。 – Hauleth 2012-01-14 22:22:10

11

無需預編譯雜波你混帳!

的Heroku將預編譯的資產

與軌道3.1.X你加入這application.rb中

config.assets.initialize_on_precompile = false 

UPDATE 16 july2012

也軌3.2.x中

i t似乎是ActiveRecord和database.yml的問題!如果您不使用常規數據庫,但使用MongoDB,則不需要上述內容。但是,如果這樣做,則需要禁用initilize,因爲activerecord在初始化時讀取數據庫表,但數據庫在heroku的預編譯階段不可用。

MongoDB沒有必要

/UPDATE

軌3.2.x中 :看一看application.rb中的頂部。 OMA的意見是我的,增加了透明度

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    "OMA - comment this line" 
    #Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    "OMA - uncomment this line" 
    Bundler.require(:default, :assets, Rails.env) 
end 
+0

我正在運行的Rails 3.2.6的一切更新,我不得不預編譯,否則rails.png不顯示。我正在關注Rails教程在線書籍。 – tentimes 2012-06-17 14:18:09

+1

當然......希望在我嘗試過傑西的回答之前,我已經讀過了。簡單的預編譯並沒有幫助。而且...現在我的git回購臃腫。 – 2013-04-15 12:39:21

2

偷懶開始用薄(在Heroku)正與導軌3.2.3我不得不這樣做:

在配置/ application.rb中:

if defined?(Bundler) 
    # If you precompile assets before deploying to production, use this line 
    # Bundler.require(*Rails.groups(:assets => %w(development test))) 
    # If you want your assets lazily compiled in production, use this line 
    Bundler.require(:default, :assets, Rails.env) 
end 

... 


module Romulo 
    class Application < Rails::Application 

... 

    # Enable the asset pipeline 
    config.assets.enabled = true 

    # Version of your assets, change this if you want to expire all your assets 
    config.assets.version = '1.0' 

    # get precompilation working on heroku: 
    config.assets.initialize_on_precompile = true 

    config.serve_static_assets = false 
    end 
end 

在配置/環境/ production.rb:

# 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 

無需預編譯的資產。

相關問題