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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:21:09+00:00 2026-06-17T01:21:09+00:00

I have a database that was populated using a rails system. I am trying

  • 0

I have a database that was populated using a rails system. I am trying to go back and delete a list of id’s from one of the tables. I am currently deleting a single entry using the following command.

Item.find(1).destroy

I would like to be able to delete a series of id’s with a single command. (ie. 1,6,5,8,12,14)

Item.find(1,6,5,8,12,14).destroy

I know that this doesn’t work but thats the idea of what I’d like to do. I am fairly new to ruby and just trying to determine the simplest way to proceed.

  • 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-17T01:21:11+00:00Added an answer on June 17, 2026 at 1:21 am

    No need to fetch the Items manually when Rails can do it for you:

    Item.destroy_all(id: [1, 6, 5, 8, 12, 14])
    

    or, as @ShankyMunjal posted, if you can use just ids, you can go with:

    Item.destroy([1, 6, 5, 8, 12, 14])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a <table> that is populated from a mysql database using php .
I have a Spinner that's populated using a cursor containing data from a database.
I have a select box that is being populated dynamically from a database. As
i have a dropdownlist that populates from the sql server database. populating the list
I'm using a JTree that is populated from a database. The tree is created
I have a DropDownList which is populated using a sqldatasource, i.e., from database and
I have a ListView in my activity that is populated from a database Cursor
I have a database that I have populated using CREATE and INSERT INTO statements.
I have a database that has been populated with some data using create and
I have a table that is populated from a SQL database. Most of the

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.