Rails 3 - updating multiple records in one form

I am trying to create a simple inventory application, and I wanted to have a page with a list of items, only with a name label and an editable field to update the number of installations and one update button to update all of them.

My model is called an element and two fields, name and instock

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

* After playing with it, I can create a form, but when I click on the update, it gives an error: Could not find an element with ID = edit_multiple

Here is a part of my controller:

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

And here are my .rb routes

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

If anyone has pointers or help, I would appreciate it.

thanks,

+4
source share
2 answers

I had the same problem, and I decided to manually describe the path to the controller's action in the form of edit_multiple, for example:

 = semantic_form_for :isbn, :url => {:controller => 'isbns', :action => 'update_multiple'}, :html=>{:method=>:put} do |f| 
0
source

Source: https://habr.com/ru/post/1347122/


All Articles