【发布时间】:2011-12-29 17:16:49
【问题描述】:
有 2 个模型 customer 和 comm_log。它们的关联如下:
resources :customers do
comm_logs
end
comm_logs 控制器中用于销毁的 rspec 代码通过,没有任何错误。 lambda 块验证成功删除后通信日志计数减少了 1。控制器中的一切似乎都是正确的。
rake 路由的输出为:
new_customer_comm_log GET /customers/:customer_id/comm_logs/new(.:format) {:action=>"new", :controller=>"comm_logs"}
edit_customer_comm_log GET /customers/:customer_id/comm_logs/:id/edit(.:format) {:action=>"edit", :controller=>"comm_logs"}
customer_comm_log GET /customers/:customer_id/comm_logs/:id(.:format) {:action=>"show", :controller=>"comm_logs"}
PUT /customers/:customer_id/comm_logs/:id(.:format) {:action=>"update", :controller=>"comm_logs"}
DELETE /customers/:customer_id/comm_logs/:id(.:format) {:action=>"destroy", :controller=>"comm_logs"}
实际上,点击删除按钮后记录并没有被删除,页面也没有像在控制器中那样重定向到上一页(显示页面只是保留下来,删除后没有重定向到任何地方)。似乎删除操作被路由到了正确的路径。问题很可能出在视图中的下面的 link_to 上:
<%= link_to 'delete', customer_comm_log_path(@customer, @comm_log), :method => :delete, :confirm => "are you sure?", :remote => true %>
上面的link_to有什么问题吗?谢谢。
【问题讨论】:
-
你能发布你的控制器销毁方法吗?
标签: ruby-on-rails ruby-on-rails-3.1