You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: railties/guides/source/serializers.textile
-37Lines changed: 0 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -459,25 +459,6 @@ In other words, if a +PostSerializer+ is trying to serialize comments, it will f
459
459
look for +PostSerializer::CommentSerializer+ before falling back to +CommentSerializer+
460
460
and finally +comment.as_json+.
461
461
462
-
h3. Optional Associations
463
-
464
-
In some cases, you will want to allow a front-end to decide whether to include associated
465
-
content or not. You can achieve this easily by making an association *optional*.
466
-
467
-
<ruby>
468
-
class PostSerializer < ActiveModel::Serializer
469
-
attributes :title. :body
470
-
has_many :comments, :optional => true
471
-
472
-
# ...
473
-
end
474
-
</ruby>
475
-
476
-
If an association is optional, it will not be included unless the request asks for it
477
-
with an +including+ parameter. The +including+ parameter is a comma-separated list of
478
-
optional associations to include. If the +including+ parameter includes an association
479
-
you did not specify in your serializer, it will receive a +401 Forbidden+ response.
480
-
481
462
h3. Overriding the Defaults
482
463
483
464
h4. Authorization Scope
@@ -500,24 +481,6 @@ which allows you to define a dynamic authorization scope based on the current re
500
481
501
482
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.
502
483
503
-
h4. Parameter to Specify Included Optional Associations
504
-
505
-
In most cases, you should be able to use the default +including+ parameter to specify
506
-
which optional associations to include. If you are already using that parameter name or
507
-
want to reserve it for some reason, you can specify a different name by using the
0 commit comments