0
我有一个Active Record,其中包含一个数组,其中包含文件(see this),这要感谢CarrierWave及其multiloadload功能。将数据追加到对象
我想提取这些文件并将它们放入JSON。现在,JSON部分可以工作,但是我无法将这些数据添加到JSON本身。
# GET /multifiles
def index
@fichiers = Multifile.all
@multifile = {}
@fichiers.each do |m|
m.fichiers.each do |f|
path = f.url
@fichiers << path if path
end
end
render json: @fichiers
end
我读了很多计算器的消息说,这是要追加一定的参考价值的对象的方式,但是当我刷新,我得到如下:
undefined method `<<' for #Multifile::ActiveRecord_Relation:0x000000122beaa0>
我在做什么错误?
预先感谢您
谢谢你,这是silmpler,我害怕! – Jaeger