0
특정 해시로 모든 db 항목을 가져 와서 json으로 반환하고 싶습니다. 다음 코드를 사용합니다 :JSON 파일 빌드 문제
@tasks = Task.find_all_by_hash(params[:hash])
respond_to do |format|
format.json { render :json => @tasks }
end
이제 내 json 파일이 올바르지 않다는 문제점이 있습니다. 그것은 다음과 같은 출력이 있습니다
[
{
task: {
hash: "9dfca619f00f5488785f6b74ad1b590beefaee7a88c04884bf197e7679f3"
id: 4
created_at: "2010-12-16T09:09:51Z"
updated_at: "2010-12-16T09:14:10Z"
done: true
name: "Hallo"
}
},
{
task: {
hash: "9dfca619f00f5488785f6b74ad1b590beefaee7a88c04884bf197e7679f3"
id: 5
created_at: "2010-12-16T09:12:37Z"
updated_at: "2010-12-16T09:12:37Z"
done: true
name: "Test"
}
},
...
]
을하지만 사실은 내가 그것은 다음과 같이합니다 :
{ tasks: [
{"id":"1","date_added":"0001-02-22 00:00:00","post_content":"Check out my content, this is loaded via ajax and parsed with JSON","author":"Ryan Coughlin"},
{"id":"2","date_added":"0000-00-00 00:00:00","post_content":"More content, loaded. Lets try to add a form in and post via ajax and append the new data","author":"Billy Bob"}
]}
어떤 조언을? 고맙습니다!
과 같은 것이 좋습니다. 감사! – Tronic