을 "파괴"어떤 경로 일치 {: 작업이 =>에 "공헌"에 대한 사용자의 투표를 파괴하려고 할 때 나는 다음과 같은 오류를 받고 있어요
No route matches {:action=>"destroy", :controller=>"contribution_votes",
:id=>#<ContributionVote contribution_id: 8245, user_id: 40>}
그러나 왜 아무 생각이 없습니다. 여기에 요청 여기
<%= button_to "undo voteup!",
contribution.contribution_votes.find_by_user_id(current_user),
:method => :delete, :class => 'contribution_vote undo' %>
를 보내는 버튼은 컨트롤러의 "파괴"조치는 다음과 같습니다
def destroy
@vote = current_user.contribution_votes.find(params[:id])
@vote.destroy
@contribution = Contribution.find_by_id(@vote.contribution_id)
@contribution_decrement = @contribution.decrement(:votes)
if @vote.destroy and @contribution_decrement.save
respond_to do |format|
format.html {redirect_to :back}
format.js
end
else
redirect_to :back
end
end
(여기에 몇 가지 중복 내가 알고 있지만, 그것은에 기입 할 수있어 나중에)
그리고 여기가 routes.rb에서 설정의
resources :contribution_votes, :only => [:create, :destroy]
아무도 도와 줄 수 있습니까? 나는 그 대답이 분명한 것 같지만 아무데도 그것을 찾을 수 없다. 그런데
<%= button_to "undo voteup!",
contribution_votes_path(current_user.id),
:method => :delete, :class => 'contribution_vote undo' %>
...을 :
버튼의 생성 된 html을 표시 할 수 있습니까? – Nerian
@ 존 - 저는 레일에 새로 온 사람입니다. 그래서 그것을 교정하는 법을 알지는 못합니다. (왜 내가 사용하고있는 것이 중첩 된 자원인지는 모르지만 그것을 살펴볼 것입니다). 컨트롤러를 명시 적으로 설정할 수있는 방법이 있습니까? 왜 올바른 컨트롤러를 찾지 않을까요? 당신의 도움을 주셔서 감사합니다. – jonic
경로를 변경 한 후 서버를 다시 시작 했습니까? – Arsen7