mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Isolate ArraySerializer case in injection helper
This makes this special case with the ArraySerializer stand out so that the reader notices it.
This commit is contained in:
@@ -87,10 +87,12 @@ module InjectionHelper
|
||||
|
||||
def inject_json_ams(name, data, serializer, opts = {})
|
||||
if data.is_a?(Array)
|
||||
json = ActiveModel::ArraySerializer.new(data, {each_serializer: serializer}.merge(opts)).to_json
|
||||
else
|
||||
json = serializer.new(data, opts).to_json
|
||||
opts = { each_serializer: serializer }.merge(opts)
|
||||
serializer = ActiveModel::ArraySerializer
|
||||
end
|
||||
|
||||
serializer_instance = serializer.new(data, opts)
|
||||
json = serializer_instance.to_json
|
||||
render partial: "json/injection_ams", locals: {name: name, json: json}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user