2011-05-12 48 views
3

我创建了一个简单的脚手架,问题是,当我尝试删除记录时单击销毁轨道重定向到show动作,这是自动生成的链接的代码当我生成脚手架:Rails 3:脚手架销毁行动重定向以显示行动

<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %> 

怎么了?

回答

5

您需要将rails.js包含在您的应用程序布局中,因为此链接要求JS使用正确的HTTP方法。还要确保你的布局中有csrf_meta_tag

+0

好,谢谢,现在jQuery库和其他js文件的注释,并用<%= javascript_include_tag:默认%>破坏行动工作但我怎么能包括jquery和原型togheter没有冲突? – davelab 2011-05-12 14:08:04

2

检查您application.js//= require jquery_ujs

0

添加在application.js这个代码

// This is a manifest file that'll be compiled into application.js, which will include all the files 
// listed below. 
// 
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 
// 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
// the compiled file. 
// 
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 
// GO AFTER THE REQUIRES BELOW. 
// 
//= require jquery 
//= require jquery_ujs 
//= require_tree .