2013-07-12 98 views
0

我有一個簡單的Rails 3.2控制器,其被消耗與JSON一個API:導軌3個respond_with返回協會

module Api 
    module V1 
    class ReportsController < Api::V1::ApplicationController 
     def index 
     respond_with Report.where(name: params[:name]) 
     end 
    end 
    end 
end 

(沒有代碼是父控制器)

當我消耗此方法,我正在按預期收回所有報告,但我也獲得了所有的關聯。我不明白這是爲什麼,並想阻止它。

爲什麼我得到這些關聯?

+0

你如何生成你的JSON? –

+0

也許你在你的應用程序中有序列化程序的寶石,我知道它們被用來獲得與關聯的JSON響應。 – rmagnum2002

+0

@ZachKemp JSON剛剛通過Rails與'responds_with:json' –

回答

0

由於@ rmagnum2002不存在,我發現active_model_serializers捆綁到應用程序中,並且有人爲該模型創建了序列化程序,而我沒有注意到它。