0

嘿,伙计们,我不知道该怎么说,我做了一点 ror..我把我所有的工作都改成了新的一圈,我赢了 7,我的大多数项目都使用 ror 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) 
4

1 回答 1

1

这个工作需要 3 件事(你的代码是正确的)

Gemfile 必须包含

group :assets do
  gem 'jquery-rails'
end

views/layouts/application.html.(erb 或 haml)必须包含在 header 标签中

<%= javascript_include_tag 'application' %>

assets/javascripts/application.js 必须包含

//= require jquery
//= require jquery_ujs
于 2013-03-20T02:06:34.297 回答