2011-12-21 123 views
1
$ rake assets:precompile 
rake aborted! 
could not connect to server: Network is unreachable 
    Is the server running on host "192.168.163.70" and accepting 
    TCP/IP connections on port 5432? 

(See full trace by running task with --trace) 
rake aborted! 
Command failed with status (1): [/usr/local/Cellar/ruby/1.9.3-p0/bin/ruby /...] 

所以我想在我的開發盒上預編譯資產。出於某種原因,它試圖連接到生產數據庫(192.168.163.70),並且當它不能這樣做時,它會中止。rake資產:預編譯嘗試連接到生產數據庫?

它爲什麼這樣做,我該如何解決這個問題?

回答

1

我有以下線在我的Rake任務的一個文件

require File.expand_path(File.join(File.dirname(__FILE__), '../..', 'config', 'environment')) 

刪除它解決了這個問題。

+0

即使在我的項目中沒有rake任務,我也有同樣的問題。在預編譯資產時,耙子堅持連接到生產數據庫。我可以通過更改database.yml來將其生產指向dev數據庫來暫時解決此問題,但這樣可以輕鬆地將指向指向錯誤的數據庫。有更好的解決方案 – 2012-05-10 14:24:21

+0

我想嘗試調試並找到導致資產預編譯加載生產配置的原因。不幸的是,我沒有更好的建議。 – randomguy 2012-05-11 12:38:10

0

檢查您的RAILS_ENV,此時它必須設置爲production

+0

puts Rails.env在Application.load_tasks之前給出了「development」 – randomguy 2011-12-21 08:18:57

+0

'echo $ RAILS_ENV'怎麼辦?另外,請檢查你的'database.yml',也許你在這裏有錯。 – 2011-12-21 08:20:51