#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>
|