Sha256: ec8631ba22c642e4069c37aab60fdcd6e6e8949db673bb49b6133e7b2c711149

Contents?: true

Size: 425 Bytes

Versions: 23

Compression:

Stored size: 425 Bytes

Contents

class VendorTabulatrData < Tabulatr::Data

  column :name
  column :url
  column :active

  filter :product_price_range do |relation, value|
    relation = relation.joins(:products)
    if value == 'low'
      relation.group("vendors.id").having('AVG(products.price) <= ?', @controller.split)
    elsif value == 'high'
      relation.group("vendors.id").having('AVG(products.price) > ?', @controller.split)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
tabulatr2-0.9.33 spec/dummy/app/tabulatr_data/vendor_tabulatr_data.rb
tabulatr2-0.9.32 spec/dummy/app/tabulatr_data/vendor_tabulatr_data.rb
tabulatr2-0.9.31 spec/dummy/app/tabulatr_data/vendor_tabulatr_data.rb