我有一个 letrate gem https://github.com/muratguzel
我已安装它并按照自述文件页面上的说明进行操作。我在页面上放置了:
<div class="shop-review-ratings">
Service: <%= rating_for @shop, "service" %>
Price: <%= rating_for @shop, "price" %>
</div>
但是,当在控制器端时,我尝试用这条线保存评级:
@shop.rate(params[:stars], current_user.id, params[:dimension])
它说:
PG::Error: ERROR: null value in column "stars" violates not-null constraint
DETAIL: Failing row contains (24, 3, 1576, Shop, null, null, 2013-06-01 10:13:28.297843, 2013-06-01 10:13:28.297843).
: INSERT INTO "rates" ("created_at", "dimension", "rateable_id", "rateable_type", "rater_id", "stars", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id">
我的参数说:
{"score"=>"4", "controller"=>"shops", "action"=>"rate"}
我已经运行了所有需要的迁移。并置于shop.rb
:
letsrate_rateable "service", "price"
有没有人使用过这个 gem,并提示如何解决这个问题,或者有这个 gem 的工作示例?