From a0388a316f1a05999889e45eea49427cca1b2d62 Mon Sep 17 00:00:00 2001 From: Adman65 Date: Fri, 9 Dec 2011 15:43:40 +0100 Subject: [PATCH] Update readme to reflect yehuda's change from :as to :key --- README.textile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.textile b/README.textile index f31a0ddb..2b7b2acd 100644 --- a/README.textile +++ b/README.textile @@ -355,25 +355,25 @@ h4. Modifying Associations You can also rename associations if required. Say for example you have an association that makes sense to be named one thing in your code, but another when data is serialized. -You can use the :as option to specify a different name for an association. +You can use the option to specify a different name for an association. Here is an exmaple:
 class UserSerializer < ActiveModel::Serializer
-  has_many :followed_posts, :as => :posts
-  has_one :owne_account, :as => :account
+  has_many :followed_posts, :key => :posts
+  has_one :owned_account, :key => :account
 end
 
-Using the :as without a :serializer option will use implicit detection +Using the :key without a :serializer option will use implicit detection to determine a serializer. In this example, you'd have to define two classes: PostSerializer and AccountSerializer. You can also add the :serializer option to set it explicitly:
 class UserSerializer < ActiveModel::Serializer
-  has_many :followed_posts, :as => :posts, :serializer => CustomPostSerializer
-  has_one :owne_account, :as => :account, :serializer => PrivateAccountSerializer
+  has_many :followed_posts, :key => :posts, :serializer => CustomPostSerializer
+  has_one :owne_account, :key => :account, :serializer => PrivateAccountSerializer
 end