【问题标题】:uninitialized constant ActionView::CompiledTemplates::RAILS_ENV未初始化的常量 ActionView::CompiledTemplates::RAILS_ENV
【发布时间】:2014-03-24 14:03:28
【问题描述】:

我将此添加到我的 application.html.erb 文件中:

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

我在这一行得到了错误uninitialized constant ActionView::CompiledTemplates::RAILS_ENV

当我关闭if RAILS_ENV == 'production' 时,错误消失了,但这不是假设工作正常吗?错误试图告诉我什么?

【问题讨论】:

    标签: ruby-on-rails


    【解决方案1】:

    RAILS_ENV 应该是环境变量数组ENV 中的一个键。试试:

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

    或者,

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

    【讨论】:

      猜你喜欢
      • 2012-04-29
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      • 1970-01-01
      • 2015-12-29
      相关资源
      最近更新 更多