2012-04-29 114 views
2

我的Rails應用程序在開發模式下工作得很好,但是如果我將其更改爲生產模式,它會給出錯誤的錯誤信息,我看不到任何原因。你知道任何可能的問題嗎?更改導軌env。到生產

這是我的錯誤信息:

Started GET "/favicon.ico" for 127.0.0.1 at Mon Apr 30 00:55:16 +0300 2012 

ActionController::RoutingError (No route matches [GET] "/favicon.ico"): 
    actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
    railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app' 
    railties (3.2.1) lib/rails/rack/logger.rb:16:in `call' 
    actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call' 
    rack (1.4.1) lib/rack/methodoverride.rb:21:in `call' 
    rack (1.4.1) lib/rack/runtime.rb:17:in `call' 
    activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
    rack (1.4.1) lib/rack/lock.rb:15:in `call' 
    rack-cache (1.1) lib/rack/cache/context.rb:132:in `forward' 
    rack-cache (1.1) lib/rack/cache/context.rb:241:in `fetch' 
    rack-cache (1.1) lib/rack/cache/context.rb:181:in `lookup' 
    rack-cache (1.1) lib/rack/cache/context.rb:65:in `call!' 
    rack-cache (1.1) lib/rack/cache/context.rb:50:in `call' 
    railties (3.2.1) lib/rails/engine.rb:479:in `call' 
    railties (3.2.1) lib/rails/application.rb:220:in `call' 
    rack (1.4.1) lib/rack/content_length.rb:14:in `call' 
    railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call' 
    rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:162:in `start' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' 
    /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:95:in `start' 
    /home/erogol/.rvm/ru 

感謝所有關心......

當我輸入耙資產

:預編譯我:

rake aborted! 
no such file to load -- uglifier 
    (in /home/erogol/Dropbox/Bunch_It/app/assets/javascripts/application.js) 

Tasks: TOP => assets:precompile:primary 
(See full trace by running task with --trace) 
rake aborted! 
Command failed with status (1): [/home/erogol/.rvm/rubies/ruby-1.8.7-p358/b...] 

Tasks: TOP => assets:precompile 
(See full trace by running task with --trace) 
+3

有可能是因爲這個:)原因:) –

+0

你能更具體嗎?請複製/粘貼確切的錯誤信息。另外,您是否遷移生產數據庫? –

+0

我做了所有db設置 – erogol

回答

0

問題是關於config.assets.compress = true。它會產生有關我的JavaScript文件的問題。我將它設置爲false,我的應用程序開始工作就好了。但是我不知道是否讓它失效會導致我的程序丟失。

1

從錯誤信息,它據說Rails無法找到文件:/favicon.ico。請確保它存在。

+0

它存在。我想問題是關於緩存或類似的東西。但我還搞不清楚。 – erogol

+0

它存在於哪裏?哪個文件夾?你是否使用過資產管道?你的rails服務器是否可以訪問? (例如國防部755) –

1

我的第一個猜測,如果這只是在生產中,而不是在開發中,你可能需要編譯你的資產。你會需要或者運行:

rake assets:precompile 

或更改production.rb環境文件包括:

config.assets.compile = true 

然而,在錯誤mesage路徑就是/favicon.icoassets/favicon.ico。而且,favicon文件應該只在您的/public目錄中。你能確認這是文件所在的位置嗎?

+0

我照你所說的做了,我把favicon的位置改爲公用文件夾,然後改變引用,但仍然給出相同的錯誤。另外在開發模式中爲什麼不給出有關favicon的錯誤,如果它的位置錯了? – erogol

+0

另外耙資產:預編譯不起作用,所以我只是改變production.rb,就像你說的那樣。 – erogol

+0

請看耙子編輯錯誤信息 – erogol

2

嘗試在\config\environments\production.rb文件中設置config.serve_static_assets = true。這幫助了我。