motion-prime/models/sync.rb in motion-prime-0.4.2 vs motion-prime/models/sync.rb in motion-prime-0.4.3

- old
+ new

@@ -159,11 +159,11 @@ if data # Update/Create existing records data.each do |attributes| model = old_collection.detect{ |model| model.id == attributes[:id]} unless model - model = key.singularize.to_s.classify.constantize.new + model = key.classify.constantize.new self.send(:"#{key}_bag") << model end model.fetch_with_attributes(attributes) model.save if sync_options[:save] end @@ -189,10 +189,10 @@ api_client.get normalize_sync_url(options[:sync_url]) do |response, status_code| data = options.has_key?(:sync_key) ? response[options[:sync_key]] : response if data.present? model = self.send(key) unless model - model = key.singularize.to_s.classify.constantize.new + model = key.classify.constantize.new self.send(:"#{key}_bag") << model end model.fetch_with_attributes(data) model.save if sync_options[:save] block.call(data, status_code, response) if use_callback \ No newline at end of file