persist a shift's officer data

This commit is contained in:
rgarcia
2017-09-08 20:08:45 +02:00
parent 2fafb067cc
commit 47564a91a0
6 changed files with 53 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ class Poll
validates :date, presence: true
validates :date, uniqueness: { scope: [:officer_id, :booth_id] }
before_create :persist_data
after_create :create_officer_assignments
def create_officer_assignments
@@ -18,5 +19,11 @@ class Poll
Poll::OfficerAssignment.create!(attrs)
end
end
def persist_data
self.officer_name = officer.name
self.officer_email = officer.email
end
end
end