我的控制器中的操作有问题 - 当我在视图中调用 link_to 并使用销毁操作时出现错误:
ActionController::UrlGenerationError
No route matches {:controller=>"user_votes", :action=>"destroy", :recipient_uid=>2911238}
路线:
App::Application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :users
resources :votes
resources :user_votes
root 'main#home'
end
用户投票控制器:
class UserVotesController < ApplicationController
def destroy
@user_vote = UserVote.find_by(params[:recipient_uid])
@user_vote.destroy
redirect_to root_url
end
end
查看文件:
= link_to 'Delete', {controller: "user_votes", action: "destroy", recipient_uid: friend.uid}, method: "delete"
你能告诉我我在哪里犯了错误吗?
谢谢!