# Problem with deleting multiple users

**URL:** <https://www.ruby-forum.com/t/problem-with-deleting-multiple-users/165703>\
**Category:** Rails\
**Created:** [April 16, 2009, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-deleting-multiple-users/165703 "2009-04-16T15:45:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marika](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@marika](https://www.ruby-forum.com/u/marika)\
**Post date:** [April 16, 2009, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-deleting-multiple-users/165703/1 "2009-04-16T15:45:27Z")

</div>

Hello!

I’m a beginner with ruby on rails, so I don’t really know what I’m doing  
😉

I have a index.html.erb where I list users. Before every user is a  
checkbox, which I’d like to use when destroying several users.

I hope someone can help me 🙂

index.html.erb:

 \<% form\_tag destroy\_marked\_users\_path, :method =\> :put do %\> \<% for user in @users %\> \<%# @users.each do |user| %\> \<% end %\>

| Name |
| --- |
| \<%= check\_box\_tag "user\_ids[]", user.id %\> | \<%=h user.name %\> | \<%= link\_to 'Show', user\_links\_path(user) %\> | \<%= link\_to 'Edit', edit\_user\_path(user) %\> | \<%= link\_to 'Destroy', user, :confirm =\> 'Are you sure?', :method =\> :delete %\> |

\<%= submit\_tag "Destroy\_marked" %\> \<% end %\>

* * *

In user\_controller.rb I have:  
def destroy\_marked  
@user.destroy\_all(:id =\> params[:user\_ids])  
end

* * *

and routes.rb:  
map.root :controller =\> “home”  
map.resources :users, :has\_many =\> :links, :collection =\> {  
:destroy\_marked =\> :put }

When I click Destroy\_marked on index-page, I get error:‘Couldn’t find  
User with ID=destroy\_marked’

I guess there is something wrong with routes? I just can’t figure out  
what, I don’t understand the routes ☹

Here is the development.log (it shouldn’t say ‘Processing  
UsersController#update’???) :  
Processing UsersController#index (for ::ffff:127.0.0.1 at 2009-04-16  
13:10:35) [GET]  
[4;35;1mUser Load (1.2ms) [0m [0mSELECT \* FROM “users” [0m  
Rendering template within layouts/users  
Rendering users/index  
[4;36;1mCACHE (0.0ms) [0m [0;1mSELECT \* FROM “users” [0m  
Completed in 46ms (View: 22, DB: 1) | 200 OK [[http://localhost/users](http://localhost/users)]

Processing UsersController#update (for ::ffff:127.0.0.1 at 2009-04-16  
13:10:38) [PUT]  
Parameters: {“commit”=\>“Delete marked”,  
“authenticity\_token”=\>“Ir9CWYijcM2LnHs1TShkUY6p4m4Czzl7+Cgyl+PEtVA=”,  
“user\_ids”=\>[“8”, “9”], “id”=\>“destroy\_marked”}  
[4;35;1mUser Load (0.2ms) [0m [0mSELECT \* FROM “users” WHERE  
(“users”.“id” = 0) [0m

ActiveRecord::RecordNotFound (Couldn’t find User with  
ID=destroy\_marked):  
app/controllers/users\_controller.rb:97:in `find_user' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’  
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start\_thread’  
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start\_thread’  
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each’  
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start’

Rendered rescues/\_trace (102.7ms)  
Rendered rescues/\_request\_and\_response (0.5ms)  
Rendering rescues/layout (not\_found)

* * *

Here is also rake routes -result:  
users GET /users(.:format) {:controller=\>“users”, :action=\>“index”}  
POST /users(.:format) {:controller=\>“users”, :action=\>“create”}  
new\_user GET /users/new(.:format) {:controller=\>“users”,  
:action=\>“new”}  
edit\_user GET /users/:id/edit(.:format) {:controller=\>“users”,  
:action=\>“edit”}  
user GET /users/:id(.:format) {:controller=\>“users”,  
:action=\>“show”}  
PUT /users/:id(.:format) {:controller=\>“users”, :action=\>“update”}  
DELETE /users/:id(.:format) {:controller=\>“users”, :action=\>“destroy”}  
root / {:action=\>“index”, :controller=\>“home”}  
destroy\_marked\_users PUT /users/destroy\_marked(.:format)  
{:controller=\>“users”, :action=\>“destroy\_marked”}  
GET /users(.:format) {:controller=\>“users”, :action=\>“index”}  
POST /users(.:format) {:controller=\>“users”, :action=\>“create”}  
GET /users/new(.:format) {:controller=\>“users”, :action=\>“new”}  
GET /users/:id/edit(.:format) {:controller=\>“users”,  
:action=\>“edit”}  
GET /users/:id(.:format) {:controller=\>“users”, :action=\>“show”}  
PUT /users/:id(.:format) {:controller=\>“users”, :action=\>“update”}  
DELETE /users/:id(.:format) {:controller=\>“users”, :action=\>“destroy”}  
user\_links GET /users/:user\_id/links(.:format)  
{:controller=\>“links”, :action=\>“index”}  
POST /users/:user\_id/links(.:format) {:controller=\>“links”,  
:action=\>“create”}  
new\_user\_link GET /users/:user\_id/links/new(.:format)  
{:controller=\>“links”, :action=\>“new”}  
edit\_user\_link GET /users/:user\_id/links/:id/edit(.:format)  
{:controller=\>“links”, :action=\>“edit”}  
user\_link GET /users/:user\_id/links/:id(.:format)  
{:controller=\>“links”, :action=\>“show”}  
PUT /users/:user\_id/links/:id(.:format) {:controller=\>“links”,  
:action=\>“update”}  
DELETE /users/:user\_id/links/:id(.:format) {:controller=\>“links”,  
:action=\>“destroy”}
