File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
lib/active_model/serializer Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,19 @@ def find_serializable(object)
9393 if target_serializer
9494 target_serializer . new ( object , source_serializer . options )
9595 elsif object . respond_to? ( :active_model_serializer ) && ( ams = object . active_model_serializer )
96- ams . new ( object , source_serializer . options )
96+ source_association = source_serializer . object . class . to_s . underscore . downcase
97+ plural_source_association = source_association +'s'
98+ except = ams . _associations . keys . map ( &:to_s ) . find do |association |
99+ association == source_association || association == plural_source_association
100+ end
101+ _options = source_serializer . options
102+ _options [ :except ] = Array ( _options [ :except ] )
103+ if not except . nil?
104+ if not _options [ :except ] . include? except . to_sym
105+ _options [ :except ] . push ( except . to_sym )
106+ end
107+ end
108+ ams . new ( object , _options )
97109 else
98110 object
99111 end
You can’t perform that action at this time.
0 commit comments