/ / Como posso verificar se current_user gostou ou não? - rubi-sobre-trilhos, rubi-sobre-trilhos-3

Como posso verificar se o current_user gostou ou não? - rubi nos trilhos, rubi nos trilhos-3

Estou usando rails3, devise e ats_as_votable

Eu preparei a vista para mostrar "favorito" ou "desmarcar" dependendo de sua situação de votação.
Mas não tenho ideia do que colocar. Alguém tem ideia?

<% 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 %>

Respostas:

1 para resposta № 1

Podes tentar

current_user.voted_for? @community

upd: Exemplo da documentação https://github.com/ryanto/acts_as_votable#the-voter

@user.likes @comment1

@user.voted_for? @comment1 # => true