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 7769807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:14:59+00:00 2026-06-01T16:14:59+00:00

Ok so I have a delete users button <button id=delete data=<%= user_path(@user) %>>Delete User</button>

  • 0

Ok so I have a delete users button

  <button id="delete" data="<%= user_path(@user) %>">Delete User</button>

which is using the jquery ui

   $("#delete").button();

and i want the clicking to delete the user so i have

   $("#delete").click(function(){
      if(confirm("Are you sure?")){
          var url = $(this).attr('data');
          $.post(url, {_method:'delete'}, null, "script");
          document.location = '<%= users_path %>';
          return false;
      } else {
          return false;
      }
   });

All works great but when the page refreshes I get no flash from my destroy action

def destroy
  User.find(params[:id]).destroy
  flash[:success] = "User deleted."
  redirect_to users_path
end

Any suggestions on how to fix this or restructure what i have done. I cant just use a link_to or button_to for styling purposes

  • 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-01T16:15:00+00:00Added an answer on June 1, 2026 at 4:15 pm

    Flash data only exists for the following request. It is being “eaten” by your AJAX postback.

    When you post via $.post, you’re actually making two requests; the delete requests follows the redirect and issues a get request to users_path. That request sees the flash data. When you then set your document.location to users_path, there is no longer any flash data to render.

    You absolutely should not be handling this through hand-rolled AJAX. Allow your link to be clicked like a regular link and allow Rails’ UJS to handle the post-back/confirm dialog. This should in no way impact your ability to style the link unless you’re doing something very wrong.

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

Sidebar

Related Questions

I want to have a delete user link in a normal Activerecord table, but
i have list of rows that user select and i want to delete them,
I want to allow users as well as me(the admin) to delete data in
I have a delete button in each row of GridView (component ASP.NET). I want
I have JS : jQuery('.unblock').click(function(){ var num = jQuery('.page.active').text(); var ban_id = jQuery('.unblock').attr('id'); jQuery.post('http://127.0.0.1/auth_system_1/user_activity/delete_user_ban',
We have an application that allows users to add/edit/replace/delete content (text, images, swfs, mp3s,
I have a delete form wherein the user will enter the pnum to be
I have a Rails 3.1.3 app which uses devise for users authentication and soft-deletes
I have a simple form where a user can add, edit, and delete people
I have database application, I want to allow the user to restore the deleted

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.