我有jquery发布
params[:comment][:attachments] = 09ff86a136c05c82a43fed917e5cdbe9bc44e11a82329c6e923935671ed4bf6b, 840bc6197294c6a8c4393803fa16463d28a2520b33d4a0520e905f8b83399d11
然后我希望能够遍历Rails中逗号分隔的列表,这是我到目前为止所拥有的:
params[:comment][:attachments].each do |uuid|
uuid
end
问题是uuid是否列出了整个字符串..想法在Rails中循环逗号分隔列表?
由于
答案 0 :(得分:4)
params[:comment][:attachments].split(/, ?/).each ...
答案 1 :(得分:1)
制作一个数组
params[:comment][:attachments].split(",").each do |uuid|
#stuff
end