我正在使用rails3,devise和acts_as_votable
我准备了视图,根据他的投票情况显示'书签'或'取消书签' 但我不知道该放什么。有人有想法吗?
<% if xxxxxxxxxxxx %> <= *when @community hasn't been voted by current_user*
<%= link_to t('.bookmark', :default => t("helpers.links.bookmark")),
bookmark_community_path(@community), :class => 'btn' %>
<% else %>
<%= link_to t('.unbookmark', :default => t("helpers.links.unbookmark")),
bookmark_community_path(@community), :class => 'btn-danger' %>
<% end %>
答案 0 :(得分:1)
你可以尝试
current_user.voted_for? @community
更新:文档https://github.com/ryanto/acts_as_votable#the-voter
中的示例@user.likes @comment1
@user.voted_for? @comment1 # => true