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
这样的方法,但我无法弄清楚如何在类中的自我方法中迭代结果。
谢谢