0
나는 Thumbs_Up 보석을로드했으며 투표가 정상적으로 작동합니다. Ruby On Rails : 엄지 손가락 투표 투표 집계 결과
나는 게시물 컨트롤러에이 코드를 추가 :def poll_winners
@posts = Post.tally(
{ :at_least => 1,
:limit => 20,
:order => 'vote_count desc'
})
난 그냥 표시 할 얻기 위해 실제보기에 넣어 무엇을 알아낼 수 없습니다.
그냥 <% poll_winners %>
입니까?
EDIT2 : (이 맞다면 확실하지)
undefined local variable or method `poll_winners' for #<#<Class:0x000000040a4278>:0x007f55806c3360>
* 편집 * 여기 내 전체 게시물 컨트롤러 :
class PostsController < InheritedResources::Base
def vote_up
begin
current_user.vote_for(@post = Post.find(params[:id]))
redirect_to [@post]
flash[:success] = "You have voted successfully"
rescue ActiveRecord::RecordInvalid
redirect_to [@post]
flash[:error] = "You have already voted"
end
end
def poll_winners
@posts = Post.tally(
{ :at_least => 1,
:at_most => 10000,
:limit => 10,
:order => 'vote_count desc'
})
end
end
을 다음과 같은 방법이 있다고 가정입니까? 클래스가 PostsController 1, : at_most => 10000, : 제한 => 10, : 주문 => 'vote_count desc' }) end end –
메시지 : 정의되지 않은 지역 변수 또는 # <# <클래스 : 0x000000040a4278> : 0x007f55806c3360> –
의'poll_winners '메소드'poll_winners' 메소드를 컨트롤러에서 헬퍼로 이동하십시오. 헬퍼 폴더에는'post_helper.rb'라는 파일이 있어야합니다. –