【问题标题】:NameError in Spree::Products#showSpree::Products#show 中的 NameError
【发布时间】:2013-11-24 17:37:16
【问题描述】:

此代码曾经在 rails 3.2.13 和 spree 2.0 上工作,现在在 rails 4.0 和 spree 2.1 上会引发以下错误。

Showing /var/lib/gems/1.9.1/gems/spree_frontend-2.1.1/app/views/spree/products/show.html.erb where line #19 raised:

undefined local variable or method `active_record' for #<ActiveRecord::Associations::JoinDependency::JoinAssociation:0xb3187c8>

提取的源代码(第 19 行附近):

 <% Spree::PROPERTIES_LEFT.each do |show_type| %>
   <% unless @product_properties.hash_for(show_type).empty? %>
     <% for title in @product_properties.hash_for(show_type).keys %>

       <h6 class="product-section-title"><%= title %></h6>

Rails.root:/home/anakin/SpreeTravelData/openjaf/spree_travel_demo

第 19 行是:

 <% unless @product_properties.hash_for(show_type).empty? %>

我该如何解决这个问题?

【问题讨论】:

  • @product_properties 设置为什么?你使用的是什么版本的rails?看起来a commit related to this in rails 合并在 4.0.0 和 4.0.1.rc4 之间,所以我猜你是在 4.0.0 上……如果你升级到 4.0.1,错误还会发生吗?

标签: ruby ruby-on-rails-4 spree


【解决方案1】:

我认为您应该尝试清理您的环境并进行干净的 bundle installbundle update 当您离线使用 rails 时,很难获得在所有依赖项上。我有这个确切的问题,这就是要走的路。可悲的是上网或发疯。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    相关资源
    最近更新 更多