Module: Caboose::ProductsHelper

Defined in:
app/helpers/caboose/products_helper.rb

Instance Method Summary collapse

Instance Method Details

#active_productsObject


18
19
20
# File 'app/helpers/caboose/products_helper.rb', line 18

def active_products
  Caboose::Product.active
end

#average_review(product_id) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/caboose/products_helper.rb', line 4

def average_review(product_id)
  all_reviews = Review.where(:product_id => product_id)
  score = 0
  count = 0
  all_reviews.each do |r|
    if r.rating && r.rating != 0
      score += r.rating
      count += 1
    end
  end
  return score/count if count > 0
  return 0
end

#caboose_sort_optionsObject


22
23
24
# File 'app/helpers/caboose/products_helper.rb', line 22

def caboose_sort_options
  render :partial => '/caboose/products/sort_options'
end