【发布时间】: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