2014-01-09 76 views
0

我遇到了一個問題,無論我在哪種環境下運行Rails,它總是會投入生產。例如:Rails總是使用生產環境

$ rails c development 
Loading production environment (Rails 3.2.16) 
1.9.3p484 :001 > 

$ RAILS_ENV=development rails console 
Loading production environment (Rails 3.2.16) 
1.9.3p484 :001 > 

我第一次注意到這一點,當我運行Rails服務器並將其寫入生產數據庫,而不是發展。如果我運行「rails s -e development」,它表示它在開發中啓動,但仍使用生產數據庫。

這是我到config/environment.rb

# Load the rails application 
require File.expand_path('../application', __FILE__) 

# Initialize the rails application 
Skeletor::Application.initialize! 

我試圖通過項目grepping,看是否是被設置RAILS_ENV任何地方,但我沒有看到它。

+0

你的database.yml文件是什麼樣的? – ChrisBarthol

+0

在bash/zsh/etc中運行'env'的輸出是什麼? –

+0

Rails.env在控制檯中的價值 – junil

回答

0

在初始化我做了「如果Rails.env =‘生產’」,而不是「如果Rails.env ==‘生產’」,這是造成問題的原因。感謝大家的建議,我知道它必須是愚蠢的東西。

+0

http://en.wikipedia.org/wiki/Yoda_conditions:D –

0

嘗試運行:

RAILS_ENV=development bundle exec rails s