lib/is_reviewable/reviewable.rb
# Calculate average rating for this reviewable object.
# 
Calculate average rating for this reviewable object.
Calculate average rating for this reviewable object .
def average_rating(recalculate = false)
        if !recalculate && self.reviewable_caching_fields?(:average_rating)
          self.average_rating
        else
          conditions = self.reviewable_conditions(true)
          conditions[0] << ' AND rating IS NOT NULL'
          ::Review.average(:rating,
            :conditions => conditions).to_f.round(self.is_reviewable_options[:total_precision])
        end
      end
def average_rating ( recalculate = false ) if ! recalculate && self . reviewable_caching_fields? ( :average_rating ) self . average_rating else conditions = self . reviewable_conditions ( true ) conditions [ 0 ] << ' AND rating IS NOT NULL' :: Review . average ( :rating , :conditions => conditions ) . to_f . round ( self . is_reviewable_options [ :total_precision ] ) end end
Calculate average rating for this reviewable object.
Calculate average rating for this reviewable object .
recalculate
<not_specific>