Ratings demo

So this is how you get the average of the rating for each vendor:
-On the vendor model you add a "has_many :reviews" so that you can reference all reviews for that vendor.
-On the vendor model, you first get how many reviews that vendor has. If he has 0, return 0 as rating, else just call the average function on the field :rating, which is in the table reviews.
-Finally, in your view just call the function you just created to get the average you need as: <%= vendor.average_rating %>