1
我试图在我的rails应用程序中实现星级评分系统。我选择使用ajaxful-rating宝石。rails星级评分系统 - ajaxful评级
- 我已经安装了宝石
- 我跑我添加ajaxful_rateable到我的装备模型,以使他们评级的脚本
- 。
- 我已将ajaxful_rater添加到我的用户模型以启用评分其他项目。
我并没有完全通过安装,因为我遇到了路由错误。我需要知道我在路由或数据库上做了什么错误。根据宝石上的指示,除了缓存平均评分之外,似乎并不需要增加数据库。但是当我尝试访问视图时出现以下错误:
Mysql2::Error: Table 'equiptme.rates' doesn't exist: SHOW FULL FIELDS FROM `rates`
请帮忙。我的代码如下。
路线
resources :gears, :member => {:rate => :post} do
resources :calendars, :only => [:create, :destroy, :edit]
resources :comments, :only => [:create, :destroy]
end
查看
<% @comments.each do |comment| %>
<div style="width: 99%; min-height: 190px; margin-bottom: 30px; border-bottom: 1px dotted #DAD9D9;">
<div style="width: 17%; float: left; overflow: hidden; margin-left: 10px; text-align: center; font-size: 14px; ">
<div class="gearcomments_userpic_container"><%= image_tag comment.user.userimage.url(:comments), :class => "gearcomments_userpic" %></div></br>
<%= comment.user.name %>
</div>
<div style="width: 55%; float: left; margin-left: 10px; font-size: 13px;">
<%= comment.body %>
</div>
<div style="width: 15%; float: left; text-align: center;">
<h4>Overall Rating</h4></br>
<%= ratings_for @gear, :show_user_rating => true %>
<div></div></br>
<% # display delete link only for comments written by this particular user %>
<% if user_signed_in? and comment.user_id == current_user.id %>
<span><%= link_to 'delete', gear_comment_path(@gear, comment), :confirm => 'Are you sure?', :method => :delete, :class => "" %></span>
<% end %>
</div>
</div>
<% end %>
齿轮模型
class Gear < ActiveRecord::Base
...
ajaxful_rateable :stars => 6, :allow_update => true
end
用户模型
class User < ActiveRecord::Base
...
ajaxful_rater
end
哇......我不敢相信我错过了那个。谢谢! – DaveG