From 617d1d51f382798f8ecab1dff7985e7f50d058ff Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 7 Feb 2013 11:13:26 -0500 Subject: [PATCH] update server-assigned attributes after saving objects --- app/models/orvos_base.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/orvos_base.rb b/app/models/orvos_base.rb index 96016059ca..9a02001c9b 100644 --- a/app/models/orvos_base.rb +++ b/app/models/orvos_base.rb @@ -55,9 +55,18 @@ class OrvosBase < ActiveRecord::Base resp = $orvos_api_client.api(self.class, '', postdata) end return false if !resp[:etag] || !resp[:uuid] + + # set read-only non-database attributes @etag = resp[:etag] @kind = resp[:kind] - self.uuid ||= resp[:uuid] + + # these attrs can be modified by "save" -- we should update our copies + %w(uuid owner created_at + modified_at modified_by_user modified_by_client + ).each do |attr| + self.send(attr + '=', resp[attr.to_sym]) + end + self end def save! -- 2.30.2