A. 现有 我正在制造一个小目标如下:
@comments = Array.new
comments.collect do |comment|
@comments << {
:id => comment.id,
:content => html_format(comment.content),
:created_at => comment.created_at
}
end
@comments.to_json
而这种回报是:
[{"created_at":"2011-03-02T09:17:27-08:00","content":"<p>Random.......</p>","id":734}, {"created_at":"2011-03-02T09:17:27-08:00","content":"<p>asdasd.......</p>","id":714}, {"created_at":"2011-03-01T09:17:27-08:00","content":"<p>Random.......</p>","id":134}, {"created_at":"2011-03-01T02:17:27-08:00","content":"<p>dasdasdasdasd.......</p>","id":3124}]
这里的问题是,我需要列入一些其他零件。 我想要的是,有色人反对这样做:
[comments: {"created_at":"2011-03-02T09:17:27-08:00","content":"<p>Random.......</p>","id":734}, {"created_at":"2011-03-02T09:17:27-08:00","content":"<p>asdasd.......</p>","id":714}, {"created_at":"2011-03-01T09:17:27-08:00","content":"<p>Random.......</p>","id":134}, {"created_at":"2011-03-01T02:17:27-08:00","content":"<p>dasdasdasdasd.......</p>","id":3124}, last_load: "123123123123", last_view: "zxczcxzxczxc"]
任何关于我如何利用我前面的内容的想法,以及将其扩大到通过除评论阵列以外的其他项目的想法?
谢谢!