mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Implement has_one's and serialize_ids
This commit is contained in:
14
test/fixtures/poro.rb
vendored
14
test/fixtures/poro.rb
vendored
@@ -6,6 +6,14 @@ class Model
|
||||
def read_attribute_for_serialization(name)
|
||||
@attributes[name]
|
||||
end
|
||||
|
||||
def model
|
||||
@model ||= Model.new(attr1: 'v1', attr2: 'v2')
|
||||
end
|
||||
|
||||
def id
|
||||
object_id
|
||||
end
|
||||
end
|
||||
|
||||
class ModelSerializer < ActiveModel::Serializer
|
||||
@@ -20,3 +28,9 @@ class ModelSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :attr1, :attr2
|
||||
end
|
||||
|
||||
class AnotherSerializer < ActiveModel::Serializer
|
||||
attributes :attr2, :attr3
|
||||
|
||||
has_one :model
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user