Module: Admin::Atreides::ProductsHelper
- Includes:
- Atreides::Extendable
- Defined in:
- app/helpers/admin/atreides/products_helper.rb
Instance Method Summary collapse
- #image_column(product) ⇒ Object
- #inventory_column(product) ⇒ Object
- #product_column(product) ⇒ Object
- #sales_column(product) ⇒ Object
- #total_column(product) ⇒ Object
Instance Method Details
#image_column(product) ⇒ Object
3 4 5 |
# File 'app/helpers/admin/atreides/products_helper.rb', line 3 def image_column(product) !product.photos.empty? ? image_tag(product.photos.first.image.url(:thumb)) : "" end |
#inventory_column(product) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/admin/atreides/products_helper.rb', line 11 def inventory_column(product) content_tag(:table) do content_tag(:thead) do content_tag(:th, "Size") + content_tag(:th, "Qty") end + content_tag(:tbody) do product.sizes.map do |s| content_tag(:tr) do content_tag(:td, s.name) + content_tag(:td, s.qty) end end.join end end end |
#product_column(product) ⇒ Object
7 8 9 |
# File 'app/helpers/admin/atreides/products_helper.rb', line 7 def product_column(product) link_to product.title, edit_admin_product_path(product) end |
#sales_column(product) ⇒ Object
32 33 34 |
# File 'app/helpers/admin/atreides/products_helper.rb', line 32 def sales_column(product) Money.new(product.orders.sum(:final_amount_cents)).format end |
#total_column(product) ⇒ Object
28 29 30 |
# File 'app/helpers/admin/atreides/products_helper.rb', line 28 def total_column(product) product.sizes.sum(:qty) end |