I'm trying to delete more that just one id. I'm currently using Person.find(1).destroy
.
Is there a way that I can select more than just one data record?
I'm trying to delete more that just one id. I'm currently using Person.find(1).destroy
.
Is there a way that I can select more than just one data record?
Yes. You can write scripts in the console.
Person.find_each do |person|
if # condition for deleting
person.destroy
end
end
Alternatively, if you know all the ids...you can use a where clause and then destroy all of them.
ids = [1,2,3,4,5]
people = Person.where(id: ids) # where can take an array of ids
people.each { |person| person.destroy }