我正在使用thumbs_up gem提供用戶在我的應用中對帖子投票。我希望用戶上下投票,並遵循thumbs_up wiki中的指示開始工作。使用thumbs_up計算總票數
這裏是後控制我的投票後續行動: -
def vote_up
begin
current_user.vote(@post,:true)
redirect_to [@topic.forum,@topic]
flash[:success] = "You have voted successfully"
rescue ActiveRecord::RecordInvalid
redirect_to [@topic.forum,@topic]
flash[:error] = "You have already voted for this one"
end
end
當我點擊vote_up鏈接,我得到這個錯誤信息: -
cannot convert symbol into an integer
路線: -
resources :topics do
resources :posts do
member do
post :vote_post_up
post :vote_post_down
end
end
end
查看: -
<li> <%=link_to "Vote Up", vote_post_up_topic_post_path(@topic,post), :method => :post%></li>
這裏有什麼問題?
你可以添加一些路線,這樣我們就可以知道你的'vote_up'鏈接的樣子:) – Rohit
@Rohit我已經更新了問題 –