Skip to content

Commit 6f4f30c

Browse files
committed
1 parent 6054080 commit 6f4f30c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/active_model/serializer/association/has_many.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ class HasMany < Association
55
def initialize(name, *args)
66
super
77
@root_key = @embedded_key
8-
@key ||= "#{name.to_s.singularize}_ids"
8+
@key ||= case CONFIG.default_key_type
9+
when :name then name.to_s.pluralize
10+
else "#{name.to_s.singularize}_ids"
11+
end
12+
913
end
1014

1115
def serializer_class(object, _)

lib/active_model/serializer/association/has_one.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ class HasOne < Association
55
def initialize(name, *args)
66
super
77
@root_key = @embedded_key.to_s.pluralize
8-
@key ||= "#{name}_id"
8+
@key ||= case CONFIG.default_key_type
9+
when :name then name.to_s.singularize
10+
else "#{name}_id"
11+
end
912
end
1013

1114
def serializer_class(object, options = {})

0 commit comments

Comments
 (0)