Sha256: 33767464c86bf4fdf156f59c74296736c39cfa6929107517384b19668b14e291

Contents?: true

Size: 982 Bytes

Versions: 10

Compression:

Stored size: 982 Bytes

Contents

class ProductTabulatrData < Tabulatr::Data

  search :vendor_product_name, :price, :title

  # search do |query|
  #   "products.title LIKE '#{query}'"
  # end

  column :title
  column :id
  column :price do "#{record.price} EUR" end # <- Block evaluiert im Kontext EINES Records
  column :edit_link do link_to "edit #{record.title}", product_path(record) end
  # column :name,
  #   sort: "firstname || ' ' || lastname"
  #   filter: "firstname || ' ' || lastname"
  #   do
  #     "#{firstname} #{lastname}"
  # end
  column :vendor_product_name, sort_sql: "products.title || '' || vendors.name", filter_sql: "products.title || '' || vendors.name" do
    "#{record.title} from #{record.vendor.try(:name)}"
  end
  column :active
  column :updated_at, table_column_options: { filter: :date } do "#{record.updated_at.strftime('%H:%M %d.%m.%Y')}" end
  association :vendor, :name
  association :tags, :title do |r|
    "'#{r.tags.map(&:title).map(&:upcase).join(', ')}'"
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tabulatr2-0.8.9 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.8 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.7 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.6 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.5 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.4 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.3 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.2 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.1 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.8.0 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb