2011-10-03 97 views
0

我的rails 3應用程序始終卡在測試環境中。當我打電話Rails 3控制檯總是在測試環境中啓動

rake db:reset 

它重置測試數據庫,但不是開發人員。

當我運行下面的代碼,它加載在控制檯測試環境:

rails c 

試圖指定的開發環境也不起作用:

[email protected]:~/id$ RAILS_ENV=development rails console 
Loading test environment (Rails 3.0.8) 
ruby-1.8.7-p334 :001 > 

啓動服務器不工作通常:

rails s 

這是非常煩人的。任何想法,我應該看看解決這個問題?

由於提前,

編輯

我也試過在歷史可以追溯到更早承諾存在的問題之前,(我認爲),它並沒有解決問題...

回答

3

我發現了這個問題。我在其中一個初始值設定項中有以下幾行:

ActionMailer::Base.default_url_options[:host] = "localhost:3000" if Rails.env == "development" 
ActionMailer::Base.default_url_options[:host] = "localhost:3000" if Rails.env = "test" 

您能發現錯誤嗎?

+1

使用'Rails.env.development?'和'Rails.env.test?'的好理由 – Tijmen

3

最簡單的方法是使用RAILS_ENV環境變量設置環境可能是,如:

RAILS_ENV=test rails console 

編輯:您正在使用哪個版本的Rails?這對我3.0.7很好:

rails c [environment] 

E.g.

rails c development 
+0

我正在使用3.0.8。請在原始問題中查看我對您的建議的編輯。 – CHsurfer