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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:35:18+00:00 2026-06-08T09:35:18+00:00

If I check multiple records in my view then hit the delete button, discard

  • 0

If I check multiple records in my view then hit the delete button,
discard action will be called.

Now I only can delete(untrash) 1 record at once.
Why can’t I delete all of them at once even if I check multiple records???

view

  <%= form_tag(:action => discard, :via => 'put') do %>   
   <% @messages.each do |m| %>
      <tr>
       <td><%= check_box_tag "id",m.id %></td>
       <td><%= m.last_message.id %></td>
       <td><%= 'unread' if m.is_unread?(current_user) %></td>
       <td><%= m.last_message.created_at.to_s(:jp) %></td>
       <td><%= m.last_sender.username %></td>
       <td><%= link_to m.subject, show_messages_path(m) %></td>
      </tr>
   <% end %>
   <%= submit_tag "delete", :class => 'btn' %>
  <% end %>

controller

  def discard

      conversation = Conversation.find_all_by_id(params[:id])
    if conversation
      current_user.trash(conversation)
      flash[:notice] = "Message sent to trash."
    else
      conversations = Conversation.find(params[:conversations])
      conversations.each { |c| current_user.trash(c) }
      flash[:notice] = "Messages sent to trash."
    end
       redirect_to :back 
  end

routes

match 'messages/discard(/:id)' => 'messages#discard' , :as => :discard_messages
  • 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-08T09:35:20+00:00Added an answer on June 8, 2026 at 9:35 am

    When there are multiple inputs of the same name the last one ‘wins’ – params[:id] will be the value of the last submitted input, so only one message is deleted (this is easily visible by inspecting the value of the params hash)

    If the input name ends with [] (i.e. in your case set the name to id[] then rails will instead collect all the values into an array.

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

Sidebar

Related Questions

I am trying to figure out how I can delete multiple records using check
I am trying to delete multiple records using check boxes. I've loaded each check
I have a grid view utilizing sql data source. Now I want to delete
My page returns multiple records and need to do some action on the records
I am trying to design a form where I can select multiple records and
I have a scenario where the user can select check boxes to select multiple
From show view: I'd like to pass the shown message's id to discard action
If I need to check multiple conditions, which is the preferred way with respect
I have implemented an application with multiple check boxes with multiple layouts.I am invisible
I found this post that shows how to pass multiple check box selections to

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.