我正在将 Spree 用于电子商务应用程序,并且正在尝试验证 sku 的唯一性
Spree::Variant.class_eval do
attr_accessible :sku
validates_uniqueness_of :sku
end
然后,当我想创建新记录时,出现此错误:
undefined method `price' for nil:NilClass
Extracted source (around line #7):
4: <% content_for :sidebar do %>
5:
6: <h3>
7: <%= @product.name %><span class="sku"><%= @product.sku %></span>
8: </h3>
9: <br class="clear"><ul class="sidebar product-menu" data-hook="admin_product_tabs">
10: <li <%== ' class="active"' if current == 'Product Details' %>>