From 226cbc416038d7a8fb9bf277276e886df1792ae5 Mon Sep 17 00:00:00 2001 From: Gauthier Delacroix Date: Wed, 8 Oct 2014 16:31:09 +0200 Subject: [PATCH] Unsuffixed association keys doc --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index fbcf9152..eff8a7b0 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,18 @@ end BlogSerializer.new(object, key_format: :lower_camel) ``` +## Changing the default association key type + +You can specify that serializers use unsuffixed names as association keys by default. + +`````ruby +ActiveModel::Serializer.setup do |config| + config.default_key_type = :name +end +```` + +This will build association keys like `comments` or `author` instead of `comment_ids` or `author_id`. + ## Getting the old version If you find that your project is already relying on the old rails to_json