user2188880
user2188880

Reputation: 21

Rails 3.2.11 does a get request when its actually a delete request

Hey guys i dunno how to put this i have done a bit ror..I kinda changed all my work to my new lap and i have win 7 and i am usin ror 3.2.11 for most of my projects...The problem is that when i do

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

it renders as

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

but when i click this link it actually does a get request here are the server logs

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) 

Upvotes: 0

Views: 79

Answers (1)

Benjamin Bouchet
Benjamin Bouchet

Reputation: 13181

3 things are require for this to work (your code is correct)

Gemfile must contain

group :assets do
  gem 'jquery-rails'
end

views/layouts/application.html.(erb or haml) must contain in the header tag

<%= javascript_include_tag 'application' %>

assets/javascripts/application.js must contain

//= require jquery
//= require jquery_ujs

Upvotes: 1

Related Questions