我不太熟悉HAML或者它是如何工作的。表store_products下的“archived”列是布尔值,如果行的列为真,我想从总股票价格和库存总数中排除产品行。
以下是当前实施的代码:
.widget-body.list
%ul
%li
%span.count
= current_store.products_stock_value
= t('products.index.total_stock_value')
%li
%span.count
= current_store.products_count
= t('products.index.all_products')
我尝试了以下选项但没有成功:
.widget-body.list
%ul
%li
%span.count
= current_store.products_stock_value(filter: 'archived')
= t('products.index.total_stock_value')
%li
%span.count
= current_store.products_count(filter: 'archived')
= t('products.index.all_products')
和
- if params[:filter] == 'archived'
= t('current_store.products_stock_value')
- else
= t('products.index.total_stock_value')