From 5c847d5b5d8a7e19bfad93432a63d377688e7e06 Mon Sep 17 00:00:00 2001 From: Mojca Lorber Date: Mon, 13 May 2019 15:37:36 +0200 Subject: [PATCH] Change author of copied inventory item --- app/services/repository_actions/duplicate_rows.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/repository_actions/duplicate_rows.rb b/app/services/repository_actions/duplicate_rows.rb index 138dd0fa9..a6ada0dae 100644 --- a/app/services/repository_actions/duplicate_rows.rb +++ b/app/services/repository_actions/duplicate_rows.rb @@ -28,7 +28,7 @@ module RepositoryActions def duplicate_row(id) row = RepositoryRow.find_by_id(id) new_row = RepositoryRow.new( - row.attributes.merge(new_row_attributes(row.name)) + row.attributes.merge(new_row_attributes(row.name, @user.id)) ) if new_row.save @@ -46,10 +46,11 @@ module RepositoryActions end end - def new_row_attributes(name) + def new_row_attributes(name, user_id) timestamp = DateTime.now { id: nil, name: "#{name} (1)", + created_by_id: user_id, created_at: timestamp, updated_at: timestamp } end