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 %> + + <% end %> diff --git a/db/migrate/20111004170407_create_invoices.rb b/db/migrate/20111004170407_create_invoices.rb index 52d2372..ada6fe7 100644 --- a/db/migrate/20111004170407_create_invoices.rb +++ b/db/migrate/20111004170407_create_invoices.rb @@ -6,7 +6,7 @@ def self.up t.string :contact_email t.string :contact_person t.string :street_address - t.integer :post_code + t.string :post_code t.timestamps end diff --git a/db/schema.rb b/db/schema.rb index 4ad8fcd..1884ae3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -46,7 +46,7 @@ t.string "contact_email" t.string "contact_person" t.string "street_address" - t.integer "post_code" + t.string "post_code" t.datetime "created_at" t.datetime "updated_at" end