0
我有一個困境。在我的控制器中有一個巨大的功能來將不同類型的數據加載到視圖的一個列表中。所以我有這樣的此刻處理它的方式:ActiveRecord上的Rails方法::關聯:: CollectionProxy
customer.notes.each do |note|
to_push = {
id: note.id,
title: 'Contact Note',
type: 'note',
description: note.notes,
user: note.user,
date: note.date,
action: nil,
extras: note.customer_interests,
closed: false,
colour: '#9b59b6'
}
history.push to_push
end
我想移動,走出控制器到模型中,但我不太知道如何。我最好想要一個像customer.notes.format_for_timeline
這樣的方法,但我無法弄清楚如何在類中的自我方法中迭代結果。
謝謝