2014-03-24 46 views
0

我將此添加到我的application.html.erb文件:未初始化的常量::的ActionView :: CompiledTemplates RAILS_ENV

<%= render :partial => 'layouts/ga' if RAILS_ENV == 'production' %> 

而我得到的錯誤uninitialized constant ActionView::CompiledTemplates::RAILS_ENV這個確切的行。

當我關閉if RAILS_ENV == 'production'時,錯誤消失,但這不是假設工作正常嗎?這個錯誤試圖告訴我什麼?

回答

2

RAILS_ENV應該是環境變量數組ENV中的一個鍵。嘗試:

<%= render :partial => 'layouts/ga' if ENV["RAILS_ENV"] == 'production' %> 

,或者

<%= render :partial => 'layouts/ga' if Rails.env.production? %> 
相關問題