1
这是生成具有嵌套密钥的响应的唯一方法吗?使用ActiveModel Serializer生成嵌套响应的最佳实践
module Api
module V20150315
class ProductConfigurationSerializer < ActiveModel::Serializer
cached
delegate :cache_key, to: :object
embed :ids, include: true
attributes :id, :short_code, :rank
has_many :delivery_product_configurations,
serializer: Api::V20150315::DeliveryProductConfigurationSerializer
end
end
end
has_many
是一个串行器,它本身调用另一个串行器。这是正确的最佳方式吗?
是否有其他方法可以做到这一点?这是最有语义的方式吗?
-Jeff