link_to 删除 url 不起作用 [英] link_to delete url is not working

查看:30
本文介绍了link_to 删除 url 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下链接可以删除我的应用中的网址

I have the following link_to delete url in my app

<%=link_to "Delete",blog_path(@blog.id), :method => :delete, :class => "delete", :confirm => "Are you sure ?"%>  

它似乎不起作用.当我单击此 url 时,它只会将我带到显示路径.有人可以告诉我如何解决这个问题.谢谢.

It does not seem to be working.When I click this url, it just takes me to the show path.Can someone please tell me how to fix this. Thanks.

推荐答案

你在使用 jQuery 吗?如果是这样,我认为问题可能在于您在使用 jQuery 时没有更新 rails.js 文件.

Are you using jQuery? If so, I think the problem could be that you are using jQuery without the updated rails.js file.

在此处下载 rails.js:https://github.com/rails/jquery-ujs/raw/master/src/rails.js把它放到你的 javascripts 目录中,覆盖 rails 默认的 rails.js.

Download rails.js here: https://github.com/rails/jquery-ujs/raw/master/src/rails.js Drop it in your javascripts directory, overwriting the rails.js that comes default with rails.

添加一个 javascript 包含行以包含它.

Add a javascript include line to include it.

  <%= javascript_include_tag "rails" %>

把它放在你的 Jquery 包含标签之后.如果您不打算使用原型,您可能还想取消 javascript 默认设置.

Put this after your Jquery include tag. You probably also want to disinclude the javascript defaults if you don't plan on using prototype.

我在我的应用程序中包含了 jQuery UI,我发现删除现在可以正常工作,但是在完成上述已解决的问题之后.

I included jQuery UI in my application, I found that delete is now working as show, but after doing above Resolved Issue.

这篇关于link_to 删除 url 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆