4

I am starting a new web app and I am using Devise for the authentication.

I have got Devise working with register, login, edit and viewing the user profile. The only problem I am having is clicking the 'Delete Account' just redirects to /users and doesn't actually delete the user. What am I doing wrong?

The delete account button

= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete

As far as I know, I haven't changed anything that would break this. The delete account button I want to use is

= negative_trash_button_link_to "Cancel my account", registration_path(resource_name), :method => :delete, :confirm => "You sure?"

The negative_trash_button_link_to is in the css3buttons gem.

Edit: My routes.rb

resources :posts

ActiveAdmin.routes(self)

devise_for :admin_users, ActiveAdmin::Devise.config

root :to => "home#index"

devise_for :users do
  get "/users/sign_out" => "devise/sessions#destroy", :as => :destroy_user_session
end
resources :users, :only => :show
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

1

It would be helpful to tell us the rails version and the javascript libraries / frameworks that you have installed.

If you are using jquery or any other framework is working, test if it is working in general if is is using the appropriate helpers (for example the jquery-rails helpers in case of jquery). Most probably is a javascript issue, check also for any javascript errors.

JohnDel
  • 2,092
  • 8
  • 35
  • 64
  • The rails version is 3.1.1. And I am using jQuery, the one which is bundled with Rails in application.js –  Nov 09 '11 at 11:44
0

Look your javascript console. You seems to have a javascript error which prevent the request to be sent.

Do you have the alert "Are you sure?" before the redirection ?

jeremymarc
  • 513
  • 3
  • 15
  • I am getting no alert's popping up. –  Nov 15 '11 at 19:02
  • After adding the code from here, I am getting the pop ups now - http://stackoverflow.com/questions/3784633/delete-destroy-is-not-working-in-rails-3-with-jquery/5923346#5923346 But it now shows 'Template is missing'. "Missing template shots/destroy, inherited_resources/base/destroy, application/destroy" –  Nov 15 '11 at 19:11
  • Actually it works deleting the user with that code! :) Now I would like to delete an image or 'shot' when I click the destroy button on the image. How would I do that as it is showing that error? –  Nov 15 '11 at 19:17