当Rails 3.2.11实际上是一个删除请求时,它会发出get请求

时间:2013-03-20 01:03:25

标签: ruby-on-rails

嘿伙计们我不知道如何把这个我做了一点ror ..我有点改变了我的所有工作到我的新圈并且我赢了7并且我在3.2.11中用于我的大多数项目......问题是当我做的时候

<%= link_to("Delete", user, :method => :delete, :confirm => "Are you sure that you want to delete this user") %>

它呈现为

<a href="/users/1" data-confirm="Are you sure that you want to delete this user" data-method="destroy" rel="nofollow">Delete</a>

但是当我点击此链接时,它实际上是一个获取请求,这里是服务器日志

Started GET "/users/3" for 127.0.0.1 at 2013-03-20 06:21:40 +0530
Processing by UsersController#show as HTML
  Parameters: {"id"=>"3"}
  User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", "3"]]
  Rendered users/show.html.erb within layouts/application (0.0ms)
  Rendered layouts/_header.html.erb (2.0ms)
  User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  Rendered layouts/_body.html.erb (2.0ms)
  Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 19ms (Views: 19.0ms | ActiveRecord: 0.0ms) 

1 个答案:

答案 0 :(得分:1)

这需要做3件事(你的代码是正确的)

Gemfile必须包含

group :assets do
  gem 'jquery-rails'
end

views / layouts / application.html。(erb或haml)必须包含在标头标记

<%= javascript_include_tag 'application' %>

assets / javascripts / application.js必须包含

//= require jquery
//= require jquery_ujs