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 的时间表。但是当我想要时间表控制器的销毁操作时,它会路由到用户控制器的显示操作。感谢您的任何帮助。
My view is the users show page
<%= link_to 'Cancel?', {:url => schedule_path,
:id => current_user.schedules[0].id,
:confirm => "are you sure?",
:method => :delete} %>
Associations
has_many :schedules
belongs_to :user
routes.rb
resources :schedules
resources :users
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
link_to '取消?', Schedule_path(current_user.schedules[0]), :confirm => "你确定吗?", :method => :删除
Try to
link_to 'Cancel?', schedule_path(current_user.schedules[0]), :confirm => "are you sure?", :method => :delete