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.
No need to fetch the Items manually when Rails can do it for you:
or, as @ShankyMunjal posted, if you can use just ids, you can go with: