diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb index 4e90417..a18f2ac 100644 --- a/app/controllers/invoices_controller.rb +++ b/app/controllers/invoices_controller.rb @@ -45,9 +45,12 @@ def create def update @invoice = Invoice.find(params[:id]) - respond_to do |format| - if @invoice.update_attributes(params[:invoice]) + @invoice.update_attributes(params[:invoice]) + for user in params[:deleted_users] || [] + @invoice.users.delete(@invoice.users.find(user.to_i)) + end + if @invoice.save format.html { redirect_to(@invoice, :notice => 'Invoice was successfully updated.') } else format.html { render :action => "edit" } diff --git a/app/views/invoices/_form.html.erb b/app/views/invoices/_form.html.erb index e108d8a..85f515c 100644 --- a/app/views/invoices/_form.html.erb +++ b/app/views/invoices/_form.html.erb @@ -36,5 +36,14 @@ <%= f.submit %> +