1
我有ProfileSerializer:如何避免在has_one关联中的串行器中嵌套?
class ProfileSerializer < ActiveModel::Serializer
attributes :id, :role, :name
has_one :company
end
,我得到
{"user": {"id":7,"role":"guest","name":"misa","company":{"id":2,"user_id":7, ...}}
我有任何机会,以避免 “公司” 筑巢和获取JSON这样的:
{"user": {"user_info": {"id":7,"role":"guest","name":"misa"}, "company_info": {"id":2,"user_id":7, ...}}}