Skip to content

Commit ea6dc42

Browse files
Propagate serialization_options across associations
1 parent f1c3268 commit ea6dc42

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/active_model/serializer.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def attributes
161161
end
162162
end
163163

164-
def associations
164+
def associations(options={})
165165
associations = self.class._associations
166166
included_associations = filter(associations.keys)
167167
associations.each_with_object({}) do |(name, association), hash|
@@ -178,7 +178,7 @@ def associations
178178
if association.embed_namespace?
179179
hash = hash[association.embed_namespace] ||= {}
180180
end
181-
hash[association.embedded_key] = serialize association
181+
hash[association.embedded_key] = serialize association, options
182182
end
183183
end
184184
end
@@ -236,8 +236,8 @@ def association_options_for_serializer(association)
236236
end
237237
end
238238

239-
def serialize(association)
240-
build_serializer(association).serializable_object
239+
def serialize(association,options={})
240+
build_serializer(association).serializable_object(options)
241241
end
242242

243243
def serialize_ids(association)
@@ -282,7 +282,7 @@ def serializable_object(options={})
282282
self.serialization_options = options
283283
return @wrap_in_array ? [] : nil if @object.nil?
284284
hash = attributes
285-
hash.merge! associations
285+
hash.merge! associations(options)
286286
hash = convert_keys(hash) if key_format.present?
287287
hash = { :type => type_name(@object), type_name(@object) => hash } if @polymorphic
288288
@wrap_in_array ? [hash] : hash

0 commit comments

Comments
 (0)