- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
class Review < ActiveRecord::Base
...
def calc_total_rating
#rating received from client via form
rating_from_client = self.total_rating
#rating calculated on server
rating_from_server = ((prices_value + quality_value + delivery_value).to_f / 3).round(1)
# check if client's rating is different from automatic
if rating_from_server.to_i == rating_from_client.to_i
self.total_rating = rating_from_server
else
self.total_rating = rating_from_client
end
end
...
end
Follow us!