/ / Come posso verificare se a current_user è piaciuto o no? - ruby-on-rails, ruby-on-rails-3

Come posso verificare se a Current_user è piaciuto o no? - ruby-on-rails, ruby-on-rails-3

Sto usando rails3, ideare e act_as_votable

Ho preparato la vista per mostrare "segnalibro" o "non segnalibro" a seconda della sua situazione di voto.
Ma non ho idea di cosa mettere. Qualcuno ha idea?

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

risposte:

1 per risposta № 1

Puoi provare

current_user.voted_for? @community

upd: Esempio dalla documentazione https://github.com/ryanto/acts_as_votable#the-voter

@user.likes @comment1

@user.voted_for? @comment1 # => true