← Back to Upcase

Multiple DELETE, in a RESTful way

(Robert Lee-Cann) #1

I have a form where a user can select multiple checkboxes and then press a “Delete Selected” button to destroy the selected records from the database.

Currently, I have add the following to config/routes.rb:

collection do
  delete 'destroy_multiple'

This feels wrong, going against RESTful principles. Any suggestions to how I can improve this?

(Pedro Moreira) #2

Hi @leeky, the good news is batch requests are coming in Rails 4.2 :slight_smile:

(Robert Lee-Cann) #3

Thanks for the heads up, @pedromoreira!

Any chance you could point me towards any further information on it?

(Pedro Moreira) #4

@leeky, not really. I know that it is one of the projects coming out one the student initiatives (either the one with Facebook or Google Summer of Code) but is not on rails master yet. Maybe @sikachu can help point to the development fork?

(Derek Prior) #5

You could have a PostsCollection object and controller which takes a list of posts and performs a delete on them.

(Pedro Moreira) #6

For the sake of completeness, I believe this is the relevant PR to Rails: https://github.com/rails/rails/pull/15719