Customer というモデルがあるとします。私index.json.jbuilder
の見た目はこんな感じ
例えば
json.array!(@customers) do |customer|
json.extract! customer, :id, :name, :phone_number, :email
# some more nested fields of customer
end
私show.json.jbuilder
も同様の重複コードを持っています
json.extract! customer, :id, :name, :phone_number, :email
# some more nested fields of customer
index.json.jbuilder 内に show.json.jbuilder を含めるなど、より良い方法はありますか。json を 2 つの場所でレンダリングするロジックを複製したくありません。