HAML如果在Postgres数据库中boolean column = true,则从总成本计数中排除一行

时间:2018-04-07 19:35:08

标签: ruby-on-rails postgresql haml

我不太熟悉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')

0 个答案:

没有答案