【问题标题】:Rails CRUD - Destroy path always routes to the User show pageRails CRUD - 销毁路径总是路由到用户显示页面
【发布时间】:2011-11-09 13:29:50
【问题描述】:

我的观点是用户展示页面

<%= 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 的计划。但是当我想要销毁时,它会路由到用户控制器的显示操作调度控制器的动作。感谢您的帮助。

【问题讨论】:

  • 确保在 标签中包含 jquery 和 jquery_ujs

标签: ruby-on-rails crud restful-url restful-architecture


【解决方案1】:

尝试link_to 'Cancel?', schedule_path(current_user.schedules[0]), :confirm =&gt; "are you sure?", :method =&gt; :delete

【讨论】:

  • 这不仅解决了这个问题,还解决了其他一些问题——非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-26
  • 2017-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多