Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:14:03+00:00 2026-06-06T21:14:03+00:00

I have the following code in my Users controller in Rails to let users

  • 0

I have the following code in my Users controller in Rails to let users delete themselves:

def delete_account
User.find(params[:id]).destroy
flash[:success] = "Your account has been deleted."
redirect_to root_path
end

Now, I’m unsure of how to add the proper route to my route.rb file and then add the button correctly into my user settings view.
For my route file I have the following code:

match '/delete_account' to: 'users#delete_account'

And in my settings view file I have the following code to add a button for the delete_account action in the view:

<%= link_to class: "btn btn-danger", delete_account_path %>\

Any help you can provide in implementing the correct route and embedded ruby in my view would be greatly appreciated. Sorry if this is an easy error to fix; I’m a beginner developer, and this has been giving me some trouble.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:14:05+00:00Added an answer on June 6, 2026 at 9:14 pm

    I think it’s better to use RESTful way.

    Rename your method to destroy in controller.

    In your routes.rb,

    resources :users or match '/delete_account', to: 'users#destroy'

    In the view, say in show.html.erb,

    <%= link_to 'Delete', @user, confirm: 'Are you sure?', method: :delete %>

    And obvious your show action should find the right user,

    @user = User.find(params[:id])

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails code that sends emails. Following is in my controller: def
I have the following code: <?php echo $form->create('User', array('url' => array('controller' => 'users', 'action'
I have the following code in my controller action method: if (User.Identity.IsAuthenticated) { //
I have following code return (EseshEntities.Current.Users.Select(u => new { Comunity = u.Apartment.Building.District.City })).ToList(); if
I have the following code, that should remove the access of users from a
I have written the following code, CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(@C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt); Report works
I have following code class User attr_accessor :name end u = User.new u.name =
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
I have the following code when a user clicks in the 'generate' element the
I have the following code in one of my controllers (in a Rails 3.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.