Merge pull request #639 from gauthier-delacroix/Unsuffixed-default-associations-keys

Allow JSONAPI unsuffixed associations keys
This commit is contained in:
Steve Klabnik
2014-10-08 14:45:46 -04:00
6 changed files with 79 additions and 2 deletions

View File

@@ -5,7 +5,11 @@ module ActiveModel
def initialize(name, *args)
super
@root_key = @embedded_key
@key ||= "#{name.to_s.singularize}_ids"
@key ||= case CONFIG.default_key_type
when :name then name.to_s.pluralize
else "#{name.to_s.singularize}_ids"
end
end
def serializer_class(object, _)

View File

@@ -5,7 +5,10 @@ module ActiveModel
def initialize(name, *args)
super
@root_key = @embedded_key.to_s.pluralize
@key ||= "#{name}_id"
@key ||= case CONFIG.default_key_type
when :name then name.to_s.singularize
else "#{name}_id"
end
end
def serializer_class(object, options = {})