0

私はletsrateの宝石に本当に慣れていません。

私は現在、https://github.com/muratguzel/letsrateの wiki で例を調べています。

gem をインストールし、devise をインストールし、ユーザー モデルを生成し、レストラン モデルを生成し、シンプルな show メソッドでレストラン コントローラーを生成し、controller#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

そして私のrestaurant_controller.rbはこのように

class RestaurantsController < ApplicationController

    def show
    end 
end

これは私のエラーです。

ActionView::Template::Error (undefined method `average' for nil:NilClass):

この平均的な方法は、gem の一部である必要があります。これは宝石の問題ですか、それとも私の問題ですか? 星の平均を示すと思われます。

4

0 に答える 0