Skip to content

Commit e2f2cd8

Browse files
committed
check BOTH primary key and id for now
1 parent 794a7fb commit e2f2cd8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ruby/hyper-model/lib/active_record_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def __hyperstack_secure_attributes(acting_user)
393393
end
394394
end
395395

396-
scope __hyperstack_internal_where_scope,
396+
scope :__hyperstack_internal_where_scope,
397397
->(attrs) { where(attrs) }, # server side we just call where
398398
filter: ->(attrs) { !attrs.detect { |k, v| self[k] != v } } # client side optimization
399399

ruby/hyper-model/lib/reactive_record/server_data_cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def self.load_from_json(tree, target = nil)
506506

507507
target.send "#{method}=", value.first
508508
elsif value.is_a? Array
509-
target.send("_hyperstack_internal_setter_#{method}", value.first) unless method == target.class.primary_key
509+
target.send("_hyperstack_internal_setter_#{method}", value.first) unless [target.class.primary_key, :id].include? method
510510
elsif value.is_a?(Hash) && value[:id] && value[:id].first && (association = target.class.reflect_on_association(method))
511511
# not sure if its necessary to check the id above... is it possible to for the method to be an association but not have an id?
512512
klass = value[:model_name] ? Object.const_get(value[:model_name].first) : association.klass

0 commit comments

Comments
 (0)