拥有2个模型customer和comm_log。它们的关联如下:如何在rails 3.1中的link_to中构造删除路由?
resources :customers do
comm_logs
end
在comm_logs控制器中销毁的rspec代码没有任何错误地传递。 lambda模块验证成功删除后,通讯记录数减1。控制器中的一切看起来都是正确
耙路线的输出是:
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上面有什么问题吗?谢谢。
你可以发布你的控制器销毁方法吗? – andrewpthorp 2011-12-29 18:23:42