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, ...}}}