@@ -198,7 +198,6 @@ def self.get_type_hash(record)
198198 if RUBY_ENGINE == 'opal'
199199
200200 def self . gather_records ( records_to_process , force , record_being_saved )
201- puts "gather_records(#{ records_to_process . count } , #{ force } , #{ record_being_saved . inspect } )"
202201 # we want to pass not just the model data to save, but also enough information so that on return from the server
203202 # we can update the models on the client
204203
@@ -454,6 +453,9 @@ def self.save_records(models, associations, acting_user, validate, save)
454453 elsif parent . class . reflect_on_association ( association [ :attribute ] . to_sym ) . collection?
455454 #puts ">>>>>>>>>> #{parent.class.name}.send('#{association[:attribute]}') << #{reactive_records[association[:child_id]]})"
456455 dont_save_list . delete ( parent )
456+ if reactive_records [ association [ :child_id ] ] &.new_record?
457+ dont_save_list << reactive_records [ association [ :child_id ] ]
458+ end
457459 #if false and parent.new?
458460 #parent.send("#{association[:attribute]}") << reactive_records[association[:child_id]]
459461 # puts "updated"
@@ -463,8 +465,11 @@ def self.save_records(models, associations, acting_user, validate, save)
463465 else
464466 #puts ">>>>ASSOCIATION>>>> #{parent.class.name}.send('#{association[:attribute]}=', #{reactive_records[association[:child_id]]})"
465467 parent . send ( "#{ association [ :attribute ] } =" , reactive_records [ association [ :child_id ] ] )
468+
466469 dont_save_list . delete ( parent )
467- #puts "updated"
470+ if reactive_records [ association [ :child_id ] ] &.new_record? && parent . class . reflect_on_association ( association [ :attribute ] . to_sym ) . macro == :has_one
471+ dont_save_list << reactive_records [ association [ :child_id ] ]
472+ end
468473 end
469474 end if associations
470475
@@ -497,6 +502,7 @@ def self.save_records(models, associations, acting_user, validate, save)
497502 messages = model . errors . messages if validate && !model . valid?
498503 all_messages << [ model , messages ] if save && messages
499504 attributes = model . __hyperstack_secure_attributes ( acting_user )
505+ attributes [ model . class . primary_key ] = model [ model . class . primary_key ]
500506 [ reactive_record_id , model . class . name , attributes , messages ]
501507 end
502508
0 commit comments