我对letrate gem真的很陌生。
我目前正在浏览wiki上的示例https://github.com/muratguzel/letsrate
我安装了gem,安装了devise,生成了一个用户模型,并生成了一个餐厅模型,用简单的show方法生成了一个餐厅控制器,设置了路径到控制器#show。问题在于辅助方法,
这是我的show.html.erb模板
friendliness <%= rating_for @restaurant, "friendliness" %>
Taste : <%= rating_for @restaurant, "taste" %>
Price : <%= rating_for @restaurant, "price" %>
和我的restaurant.rb模型一样
class Restaurant < ActiveRecord::Base
# attr_accessible :title, :body
letsrate_rateable "friendliness", "price", "taste"
end
和我的restaurants_controller.rb一样
class RestaurantsController < ApplicationController
def show
end
end
这是我的错误,
ActionView::Template::Error (undefined method `average' for nil:NilClass):
这种平均方法应该是宝石的一部分。这是宝石问题还是我的问题?它假设显示星星的平均值。