Skip to content

Commit def6e8f

Browse files
committed
testing fix for #173
1 parent a8a6dfb commit def6e8f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ruby/hyper-model/lib/reactive_record/active_record/errors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def keys
8989
# person.errors.values # => [["cannot be nil", "must be specified"]]
9090
def values
9191
messages.select do |key, value|
92-
!value.empty?
92+
!value&.empty?
9393
end.values
9494
end
9595

ruby/hyper-model/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)