thumbs_up 보석이있는 게시물에 총 투표 수를 표시하려고하는데 작동하지 않는 것 같습니다. 내가 플래시 메시지 "당신은 성공적으로 투표했습니다"하지만 내 표가 표시되지 않아요 수를 얻을thumbs_up으로 총 투표 수 표시
<%="Total votes = #{@votes_total}"%>
- :
여기 내 코드 뷰에서
def vote_up
begin
post = Post.find(params[:id])
current_user.vote_for(post)
redirect_to :back
flash[:sucess] = "You have voted successfully"
@votes_total = post.votes_for
rescue ActiveRecord::RecordInvalid
redirect_to :back
flash[:error] = "You have already voted for this one"
end
end
입니다.
이
내가 내 로그 파일에있는 것입니다 : -.[1m [36m (0.3ms) [0m [1mSELECT의 COUNT (*) "표" "투표"FROM "voteable_id" = 12 AND "투표". "voteable_type"= '포스트'와 "투표". "투표"= 't'[0m 0
--- 업데이트 ---
업데이트 이 코드가있는 사후 컨트롤러 : -
def vote_up
begin
post = Post.find(params[:id])
current_user.vote_for(post)
@votes_total = post.votes_for
render :template => "home/index"
flash[:sucess] = "You have voted successfully"
rescue ActiveRecord::RecordInvalid
redirect_to :back
flash[:error] = "You have already voted for this one"
end
end
도움말.
템플릿을 렌더링해도 볼 수 없습니다 : template => "home/index" –
'render ... '위에'@votes_total = post.votes_for'를 넣어야합니다. – Mischa
예 like that like –