Add key option to serializer associations

This commit is contained in:
Rodrigo Ra
2015-07-05 19:47:58 -03:00
parent ac1991fd6b
commit df63b59512
8 changed files with 109 additions and 29 deletions

View File

@@ -228,6 +228,14 @@ PostWithTagsSerializer = Class.new(ActiveModel::Serializer) do
has_many :tags
end
PostWithCustomKeysSerializer = Class.new(ActiveModel::Serializer) do
attributes :id
has_many :comments, key: :reviews
belongs_to :author, key: :writer
has_one :blog, key: :site
end
VirtualValueSerializer = Class.new(ActiveModel::Serializer) do
attributes :id