2013-04-16 49 views
1

在我的医院申请中...在我的演示模板中销毁医生的演出记录后,它将删除记录(docperfdata/83)并重定向到索引页面(/ docperfdata)。但是我想在破坏记录后再次回到表单(/ docperfdata/new?hospital_id = 15 & id = 3061),以便用户可以再次输入他的数据。Rails在破坏后创建新的

有点像“全部清除和重新启动”

我将如何实现上述功能?

回答

0

如果你想在其他地方重定向,为什么不这样做呢?

@docperfdata.destroy 

redirect_to(new_docperfdata_path(:hospital_id => @docperfdata.hospital_id, :id => @docperfdata.id)) 
+0

日Thnx非常多的帮助,揭掉重定向......好心看看这个要点: https://gist.github.com/SkyKOG/5394338 其不工作@tadman – SkyKOG

+0

资源:performaones,:path =>“docperfdata” 我已经在routes.rb中添加了这个,以使url更有意义.... – SkyKOG

+1

This worked :) https://gist.github .com/SkyKOG/5394338 /#comment-816627 Thnx的技巧.... – SkyKOG

0

可以在控制器

def destroy 
    #destroy code here 
    redirect_to new_docperfdata_path(:hospital_id=> 15, :id=>3061) 
end 
+0

其提供了一个错误:未定义的方法销毁为零:类... prolly,因为该对象不再存在以获取ID和重定向到... 请c上述coment – SkyKOG