diff options
author | José Valim <jose.valim@gmail.com> | 2011-11-23 23:22:46 +0000 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-11-23 23:22:46 +0000 |
commit | 6da52c617e2a075b9d9e7142786f316d8f2c7930 (patch) | |
tree | 91e8507b9f633b21d44023b8e69ad872197571c8 /railties/guides/source | |
parent | 8896b4fdc8a543157cdf4dfc378607ebf6c10ab0 (diff) | |
download | rails-6da52c617e2a075b9d9e7142786f316d8f2c7930.tar.gz rails-6da52c617e2a075b9d9e7142786f316d8f2c7930.tar.bz2 rails-6da52c617e2a075b9d9e7142786f316d8f2c7930.zip |
Remove listings from the serialization guide that won't make 3.2.
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/serializers.textile | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/railties/guides/source/serializers.textile b/railties/guides/source/serializers.textile index 86a5e5ac8d..efc7cbf248 100644 --- a/railties/guides/source/serializers.textile +++ b/railties/guides/source/serializers.textile @@ -459,25 +459,6 @@ In other words, if a +PostSerializer+ is trying to serialize comments, it will f look for +PostSerializer::CommentSerializer+ before falling back to +CommentSerializer+ and finally +comment.as_json+. -h3. Optional Associations - -In some cases, you will want to allow a front-end to decide whether to include associated -content or not. You can achieve this easily by making an association *optional*. - -<ruby> -class PostSerializer < ActiveModel::Serializer - attributes :title. :body - has_many :comments, :optional => true - - # ... -end -</ruby> - -If an association is optional, it will not be included unless the request asks for it -with an +including+ parameter. The +including+ parameter is a comma-separated list of -optional associations to include. If the +including+ parameter includes an association -you did not specify in your serializer, it will receive a +401 Forbidden+ response. - h3. Overriding the Defaults h4. Authorization Scope @@ -500,24 +481,6 @@ which allows you to define a dynamic authorization scope based on the current re WARNING: If you use different objects as authorization scopes, make sure that they all implement whatever interface you use in your serializers to control what the outputted JSON looks like. -h4. Parameter to Specify Included Optional Associations - -In most cases, you should be able to use the default +including+ parameter to specify -which optional associations to include. If you are already using that parameter name or -want to reserve it for some reason, you can specify a different name by using the -+serialization_includes_param+ class method. - -<ruby> -class PostsController < ApplicationController - serialization_includes_param :associations_to_include -end -</ruby> - -You can also implement a +serialization_includes+ instance method, which should return an -Array of optional includes. - -WARNING: If you implement +serialization_includes+ and return an invalid association, your user will receive a +401 Forbidden+ exception. - h3. Using Serializers Outside of a Request The serialization API encapsulates the concern of generating a JSON representation of |