class Foo < ActiveRecord::Base has_many :foo_bars, :dependent => :destroy end class FooBar < ActiveRecord::Base belongs_to :foo end
If your attitude is similar above, the following code will work
Foo.delete_all(["id in (?)", [3,4,5,6]])
Or simply
Foo.delete([3,4,5,6])
Ref remove
edited
From little I know your question, I think you have something like the following
foo table
id some_column order 1 some_value 3 2 some_value 4 3 some_value 3 4 some_value 2 5 some_value 1 6 some_value 5 7 some_value 6
Foo_bar table
id some_column foo_id 1 some_value 2 2 some_value 1 3 some_value 3 4 some_value 2 5 some_value 4 6 some_value 5 7 some_value 6
Then the user following order instead of id
Foo.delete_all(["order in (?)", [3,4,5,6]])
source share