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