在产品页面上的Spree前端显示库存盘点

时间:2014-07-26 20:21:33

标签: ruby-on-rails-4 e-commerce spree deface

我试图在我的应用程序的前端简单地显示库存计数(狂欢管理员中显示的数字为“手头数”)。我想在产品页面上显示它,以显示有多少产品可供使用...我仍然熟悉Spree ...我可以通过前端通过更改来实现这一点吗? ?

我正在使用Spree 2-1-stable ...到目前为止我已经尝试替换_taxons partial中的无序列表(spree / frontend / app / views / spree / products / _taxons.html.erb)随着使用下面的污损覆盖计数......但我想我可能会离开基地。

Deface::Override.new(:virtual_path => 'spree/products/_taxons',
  :replace => "ul#similar_items_by_taxon",
  :text => "<%= product.total_on_hand %>",
  :name => "product_profile_changes",)

(下面的一个stackO帖子曾经说过调用total_on_hand,但这似乎也不起作用......)

Show all spree ecommerce products together with their count-on-hand displayed

我当前的代码会抛出以下错误:

SystemStackError in Spree::ProductsController#show
stack level too deep

Rails.root: /Users/user/Documents/spree_flash_sales/spec/dummy

如果我必须向控制器或模型添加一些东西,它会进入哪些特定文件以及代码是什么样的?任何帮助将不胜感激...谢谢,

1 个答案:

答案 0 :(得分:0)

嗯,我想我会留下自己的答案......另一个愚蠢的错误。

我刚刚在文本行中省略了@。即,

:text =&gt; &#34;&lt;%= @ product.total_on_hand%&gt;&#34;,

(我需要参加一些调试课程)