Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 - Update multiple records with one form

I'm trying to build a simple inventory app, and I was wanting to have a page with a list of items, with only a name label and an editable box to update the instock amount and a single update button to update them all.

My model is named item and with two fields, name and instock

I'm not sure if you need more info, thanks.

* After playing around with it, I'm able to build the form, but when I click on update, it gives the error: Couldn't find Item with ID=edit_multiple

Here is part of my controller:

   def edit_multiple
 @items = Item.find(params[:id])

And here is my routes.rb

resources :items do
collection do
  get :search
  post :edit_multiple
  put :update_multiple
end

if anyone has any pointers or help, I'd appreciate it.

thanks,

like image 416
rmp Avatar asked Apr 07 '11 15:04

rmp


1 Answers

Check out these screencasts:

  • http://railscasts.com/episodes/165-edit-multiple
  • http://railscasts.com/episodes/198-edit-multiple-individually
like image 185
fl00r Avatar answered Sep 25 '22 18:09

fl00r