Question : authlogic plugin allow users to delete their own account

so lets say i have the authlogic authentication plugin, i want to allow my users to delete their own account.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
#users_controller.rb
 
  before_filter :require_user, :only => [:show, :edit, :update]
  
  
  def new
    @user = User.new
  end
  
  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Sign-up successful!"
      Notifier.deliver_registration_confirmation(@user)
      redirect_back_or_default account_url
    else
      render :action => :new
    end
  end
  
  def show
    @user = @current_user
    render :layout => "user"
  end

  def edit
    @user = @current_user
    render :layout => "user"
  end
  
  def update
    @user = @current_user
    if @user.update_attributes(params[:user])
      flash[:notice] = "Account updated!"
      redirect_to account_url
    else
      render :action => :edit
    end
  end
  
  def destroy
    @user = @current_user
    @user.destroy
    flash[:notice] = 'User was successfully destroyed.'
    redirect_to(root_url)
  end
end

#view
<div id="delete_account_box">
		<%= link_to (image_tag "delete_account_button.png"), ????, :confirm => 'Are you sure?', :method => :delete, :id => "delete_account" %>		
	<!-- END #delete_account_box --></div>

Answer : authlogic plugin allow users to delete their own account

@user

The :method => :delete handles sending this to the destroy method in the user_controller.

Probably want to add :destroy into your before_filter, too.
Random Solutions  
 
programming4us programming4us