Rails CRUD-销毁路径始终路由到用户显示页面 [英] Rails CRUD - Destroy path always routes to the User show page
本文介绍了Rails CRUD-销毁路径始终路由到用户显示页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的看法是用户显示页面
<%= link_to 'Cancel?', {:url => schedule_path,
:id => current_user.schedules[0].id,
:confirm => "are you sure?",
:method => :delete} %>
协会
has_many :schedules
belongs_to :user
routes.rb
resources :schedules
resources :users
routes.rb中没有任何匹配项。堆栈跟踪中的参数显示 id
=> 93
,这是我想要破坏的结果ID为93的进度表。但是,当我想要进度表控制器的销毁操作时,它会路由到用户控制器的show动作。谢谢您的帮助。
I don't match anything in routes.rb. The parameters in the stack trace show id
=> 93
, which is what I want as I'm trying to destroy the schedule with id 93. But it's routing to the show action of the user's controller when I want the destroy action of the schedule's controller. Thanks for any help.
推荐答案
尝试 link_to'Cancel?',schedule_path(current_user.schedules [ 0]),:confirm => 确定吗?,:method => :删除
这篇关于Rails CRUD-销毁路径始终路由到用户显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文