2012-12-22 11 views
0

rails3, devise 및 acts_as_votable을 사용하고 있습니다.current_user가 좋아하는지 여부를 어떻게 확인할 수 있습니까?

투표 상황에 따라 '북마크'또는 '북마크 해제'를 표시 할보기를 준비했습니다.
하지만 무엇을 넣어야할지 모르겠습니다. 누구든지 아이디어가 있습니까?

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

답변

1

당신은

current_user.voted_for? @community 

UPD을 시도 할 수 있습니다 : 문서에서 예제 : 회신 https://github.com/ryanto/acts_as_votable#the-voter

@user.likes @comment1 

@user.voted_for? @comment1 # => true 
+0

덕분에 내가 대신 투표 '처럼'사용하려는 경우 ?? – HUSTEN

+0

이것은 작동하지 않습니다 : (% % current_user.likes? @community %> – HUSTEN

+0

'voted_for? '도 좋아요. 문서에서 예제를 추가했습니다. – ck3g

관련 문제