mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Update association section on README.md to reflect deprecation of the prefix of the serializer class being used as the accessor to the object we wish to serialize. (reason was previously that the name of the object being serialized is not necessarily going to be the prefix of the serializer class and worse the prefix could have been an attribute of the object itself)
This commit is contained in:
parent
720f1dabf8
commit
1b6ccbbe7b
@ -280,7 +280,7 @@ class PostSerializer < ActiveModel::Serializer
|
|||||||
|
|
||||||
# only let the user see comments he created.
|
# only let the user see comments he created.
|
||||||
def comments
|
def comments
|
||||||
post.comments.where(:created_by => scope)
|
object.comments.where(:created_by => scope)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -307,7 +307,7 @@ class PostSerializer < ActiveModel::Serializer
|
|||||||
has_many :comments
|
has_many :comments
|
||||||
|
|
||||||
def include_comments?
|
def include_comments?
|
||||||
!post.comments_disabled?
|
!object.comments_disabled?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user