渲染部分时无法找到“堆栈级太深”的根

我一直坚持这个问题一个星期。 如果你能搞清楚的话,我会给你寄一瓶苏格兰威士忌。 说真的,它来了贿赂。

关于taxons#show我正在渲染产品partial, _products.html.erb ,它将表格中的所有产品列出到taxons控制器的show视图。 单击某个产品时,默认情况下,该应用会将用户重定向到products#show _cart_local.html.erb ,其中_cart_local.html.erb部分呈现为显示“添加到购物车”选项。

但是对于taxons#show ,当点击产品时,我会调出一个灯箱,这样用户就不必离开页面了。 灯箱代码在_products.html.erb ,我正在尝试在_cart_form.html.erb内渲染_cart_form.html.erb 。 当我这样做时,我得到’堆栈级别太深’的错误,而且taxons#show将不会渲染。

但购物车在products#how #how中表现良好。 我将部分product改为@product 。 这没有用。 我渲染了一个空的部分,页面加载,这让我觉得问题是_cart_local (但为什么它会渲染products#show _cart_local ?)。

然后我拿出了开始表单标签和结束的div / end标签之间的所有代码,并且还渲染了页面,这让我认为它在那个区块中,但我不能再进一步了解它。 我被卡住了

这是_cart_local的代码,如果我取出注释之间的代码,页面呈现:

  populate_orders_path do |f| %> 
  • !v.in_stock && !Spree::Config[:allow_backorders], 'data-price' => v.price_in(current_currency).display_price %> <label for="">
<div data-hook="product_price" class="columns five alpha omega ">
'title', :in => 1..product.on_hand, :min => 1 %> 'large primary', :id => 'add-to-cart-button', :type => :submit do %>

这里是_products.html.erb ,正在加载所有产品的文件,包含灯箱,并且具有渲染购物车部分代码:

 
h(params[:keywords])) %>
    <div id="product_popup_" class="product_popup" data-popid="">
{:product => product} %>
<li id="product_" class="columns product three "classes") %>" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product"> <div class="main-image" id="single_" data-productid=""> "image", :class => "product-image", :id => product.id), product_path(product), :remote => true, :html => {:class => "product_popup"} %>
50), product, :class => 'info', :itemprop => "name", :title => product.name %> <div class="product-images" data-productid=""> 1 %>

需要帮助请叫我。 我很感激。

这是帮助者的链接,也许问题在那里? https://github.com/spree/spree/tree/v1.3.2/core/app/helpers/spree

在您的_products.html.erb部分更改:

 <%= render 'spree/shared/cart_local', :locals => {:product => product} %> 

对此:

 <%= render partial: 'spree/shared/cart_local', :locals => {:product => product} %> 

问题应该解决。

为什么? 因为按照你的方式进行操作不会将locals分成部分,这就是你收到错误的原因,通过删除locals检查。 当然最有趣的部分是为什么你在这里得到stack level too deep错误,但我现在无法找到答案。

哦,调试器是你的朋友;)

Interesting Posts